Linux #12 : Default Gateway Configuration

Default Gateway 설정은 route command를 통해서 가능합니다.
현재의 설정을 아래와 같이 확인 가능합니다.

$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.37.114.0 * 255.255.255.0 U 0 0 0 eth0
172.16.111.0 10.37.114.1 255.255.255.0 UG 0 0 0 eth0
10.37.0.0 10.37.114.1 255.255.0.0 UG 0 0 0 eth0
10.42.0.0 10.37.114.1 255.255.0.0 UG 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default 10.37.114.1 0.0.0.0 UG 0 0 0 eth0

Default Gateway의 실시간 변경을 위해서는 현재 설정된 Default Gateway를 일단 삭제 할 필요가 있습니다.
따라서 아래와 같이 실행을 해 준 다음 설정을 행하면 됩니다.

$ route delete default
$ route add default gw 10.37.114.1

Redhat 계열의 Linux의 경우 아래 File을 수정함으로서 Reboot시 자동으로 적용되게 할 수 있습니다.

$ vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=TESTSERVER
GATEWAY=10.37.114.1

설정이 완료 된 Default를 Network Restart를 통해 반영 할 수 있습니다.

$ /etc/init.d/network restart &

&를 추가하여 Background로 동작하게 하면 보다 안전하게 Restart가 가능합니다.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.