호빗의 인간세상 탐험기
Linux에서 router 설치 및 운영 방법 본문
1. Linux 컴퓨터에 router package 설치
Ubuntu가 설치된 컴퓨터에 router package를 설치하기 위해 터미널 창에서 다음 절차들을 수행한다.
1) 다음 파일의 내용을 변경하고 재부팅한다.
/etc/sysctl.conf 파일 내용 중 # net.ipv4.ip_forward = 1 내용에서 ‘#’ 부분을 제거, 저장 후 재부팅 (1은 yes, 0은 no를 의미하므로 #을 제거하면 IP forwarding을 수행하겠다는 의미임)
2) router package인 quagga를 설치한다.
# sudo apt-get install quagga
/etc/quagga directory 내에 zebra.conf와 ripd.conf 파일을 생성하여 아래와 같은 내용으로 만든다.
-- zebra.conf 파일 내용 --
hostname Router
password zebra (암호는 임의로 정해도 무관함)
enable password zebra (암호는 임의로 정해도 무관함)
-- ripd.conf 파일 내용 --
hostname ripd (암호는 임의로 정해도 무관함)
password zebra (암호는 임의로 정해도 무관함)
3) deamons 파일의 내용을 변경한다.
zebra 부분과 ripd 부분을 yes로 수정
4) /etc/services 파일의 내용을 확인한다.
port 번호 2601 ~ 부분에 현재 zebra, ripd 등의 port가 별도로 분배되어 있음
2. quagga 및 rip의 실행
quagga를 실행/재실행/중지하는 명령은 다음과 같다.
# sudo /etc/init.d/quagga start | restart | stop 또는
# service zebra start
rip daemon을 실행하는 명령은 다음과 같다. (Fedora의 경우)
# service ripd start
3. quagga로의 접속 및 운용
quagga를 실행한 후 zebra로 telnet 접속을 시도한다.
# sudo telnet localhost 2601 또는
# telnet localhost zebra
Router> enable
Router# configure terminal
Router(config)# interface eth0
Router(config-if)# ip address 192.168.1.1/24
Router(config-if)# exit
Router(config)# interface eth1
Router(config-if)# ip address 192.168.3.1/24
Router(config-if)# end
Router# write memory
Configuration saved to /etc/quagga/zebra.conf
Router# show running-config
....
Router# quit
/etc/quagga/zebra.conf 파일 내용이 위에 설정한 내용과 유사한지를 확인한다.
192.168.1.1/24과 192.168.3.1/24은 실제 eth0 및 eth1의 IP 주소이므로 네트워크 장치에 가서 이에 맞도록 IP 주소를 변경하는 것이 필요하다.
4. rip daemon으로의 접속 및 운용
RIP daemon (ripd)로 telnet 접속을 시도한다.
# sudo telnet localhost 2602 또는
# telnet localhost ripd
ripd> enable
ripd# configure terminal
ripd(config)# router rip
ripd(config-router)# network 192.168.1.0/24
ripd(config-router)# network 192.168.3.0/24
ripd(config-router)# end
Router# write memory
Configuration saved to /etc/quagga/ripd.conf
Router# show running-config
....
Router# quit
/etc/quagga/ripd.conf 파일 내용이 위에 설정한 내용과 유사한지를 확인한다.
5. static route 설정
static route를 설정한 후 show ip route로 설정 상황을 확인한다. (C는 directly connected, S는 static route를 의미함)
Router> enable
Router# configure terminal
Router(config)# ip route 192.168.1.100 255.255.255.0 eth0
Router(config)# ip route 192.168.3.100 255.255.255.0 eth1
Router(config)# end
Router# show ip route
C 192.168. ....
....
S 192.168. ....
....
Router# write memory
Configuration saved to /etc/quagga/zebra.conf
Router# show running-config
....
Router# quit
[참고사항] static route 설정 명령어
Router(config)# ip route network [mask] {address | interface} [distance] [permanent]
network : destination network
mask : destination network의 subnet mask
address : destination network에 도달하기 위한 next-hop address
interface : destination network에 도달하기 위한 next-hop router의 local interface
distance : route의 AD (Administrative Distance) value
permanent : 정의된 static route가 table에서 삭제되지 않도록 함
AD (Administrative Distance) value 변경 명령어
Router(config)# router rip
Router(config-router)# distance [1-255 distance]
router A에서 static route를 설정한 예는 다음과 같다.
Router(config)# ip route 150.150.0.0 255.255.0.0 203.210.100.1
150.150.0.0과 255.255.0.0은 destination network 주소 및 subnet mask
203.210.100.1은 1 hop을 건너뛴 IP address (즉, router B의 serial interface에 대한 IP address를 의미)
명령어 맨 뒤에 distance (라우팅 value, 작을수록 high)를 입력 가능 (default는 1)
[참고사항] rip 관련 timer 주기 설정 명령어
Router(config)# router rip
Router(config-router)# timers basic 5 30 30 40 1
숫자 순서대로 update, invalid, holddown, flush, sleep timer임
sleep timer는 최소 1ms임
default timer value는 다음과 같다.
(참고 : http://cafe.naver.com/hotsauce.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=96)
(참고 : http://blog.naver.com/loveleed?Redirect=Log&logNo=80099326253)
hello time (정기 알림 간격) 30초
invalid time (경로 만료 시간) 180초
holddown time은 invalid timer 종료 후 180초
flush time (경로 제거 시간)은 240초
sleep time (route poisoning 수신 시 긴급 update 시간)은 0초