처음 블로그를 쓰겠다고 마음먹었을 때에는 개인적으로 관심있는 부분만 기록하려고 했는데, 점점 일 얘기를 쓰게 되네요. ㅡ.ㅡ; 그래도, 같은 일이 반복되어 또다시 시간 낭비하는 것 보다는 잘 기록해 놓는게 낫겠지요.
보통 Linux 에서 네트워크 설정을 하고 문제가 있을 때는 대충 조치를 했었는데,
오늘은 운영중인 시스템이라 맘대로 바꿀 수가 없었습니다. 이 시스템은 CentOS 6.7이고,구성은 아래와 같았습니다.
[root@localhost sysconfig]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth2
0.0.0.0 100.100.100.254 0.0.0.0 UG 0 0 0 eth1
[root@localhost sysconfig]#
위와 같은 상태에서, 서버를 재시작 하면요..
[root@localhost sysconfig]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth2
위와 같이 Default Gateway가 사라져 버립니다. 이 문제를 해결해야 했지요.
우선 Default Gateway를 추가해 주면 되니, 아래 처럼 해 보았습니다.
[root@localhost network-scripts]# cat /etc/rc.d/rc.local
#!/bin/sh
touch /var/lock/subsys/local
route add default gw 100.100.100.254 dev eth1
재부팅을 해보니까 성공인 듯 해서 좋아했는데, network service 를
재시작하니 다시 문제가 발생하네요. 원격에서 접속할 일이 있는데
이런 명령이 말을 안 들으면 큰일입니다.
그래서 검색을 해 보니, metric 으로 default gateway의 우선순위를 지정하는 방법이 있네요.
다중 Ethernet port 를 가진 서버 장비에서는 이런 설정이 있어야 되는 모양입니다.
[root@localhost network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=100.100.100.118
NETMASK=255.255.255.0
GATEWAY=100.100.100.254
METRIC=0 #이렇게 추가합니다.
DNS1=8.8.8.8
이후 다른 설정파일(ifcfg-eth0 ~ eth3 ) 에서 사용하지 않는 카드는 ONBOOT=no로 처리해
줍니다. 이후 다시 확인한 routing table 은 아래와 같이 보입니다.
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth1
0.0.0.0 100.100.100.254 0.0.0.0 UG 0 0 0 eth1
[root@localhost network-scripts]#
[root@localhost network-scripts]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 100.100.100.254 0.0.0.0 UG 0 0 0 eth1
[root@localhost network-scripts]#
이후에는 서버 재시작을 하거나, service network restart 명령 이후에도 Default Gateway 설정이
유지되는 것을 확인할 수 있었습니다. :)
보통 Linux 에서 네트워크 설정을 하고 문제가 있을 때는 대충 조치를 했었는데,
오늘은 운영중인 시스템이라 맘대로 바꿀 수가 없었습니다. 이 시스템은 CentOS 6.7이고,구성은 아래와 같았습니다.
[root@localhost sysconfig]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth2
0.0.0.0 100.100.100.254 0.0.0.0 UG 0 0 0 eth1
[root@localhost sysconfig]#
위와 같은 상태에서, 서버를 재시작 하면요..
[root@localhost sysconfig]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth2
위와 같이 Default Gateway가 사라져 버립니다. 이 문제를 해결해야 했지요.
우선 Default Gateway를 추가해 주면 되니, 아래 처럼 해 보았습니다.
[root@localhost network-scripts]# cat /etc/rc.d/rc.local
#!/bin/sh
touch /var/lock/subsys/local
route add default gw 100.100.100.254 dev eth1
재부팅을 해보니까 성공인 듯 해서 좋아했는데, network service 를
재시작하니 다시 문제가 발생하네요. 원격에서 접속할 일이 있는데
이런 명령이 말을 안 들으면 큰일입니다.
그래서 검색을 해 보니, metric 으로 default gateway의 우선순위를 지정하는 방법이 있네요.
다중 Ethernet port 를 가진 서버 장비에서는 이런 설정이 있어야 되는 모양입니다.
[root@localhost network-scripts]# cat ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=100.100.100.118
NETMASK=255.255.255.0
GATEWAY=100.100.100.254
METRIC=0 #이렇게 추가합니다.
DNS1=8.8.8.8
이후 다른 설정파일(ifcfg-eth0 ~ eth3 ) 에서 사용하지 않는 카드는 ONBOOT=no로 처리해
줍니다. 이후 다시 확인한 routing table 은 아래와 같이 보입니다.
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth1
0.0.0.0 100.100.100.254 0.0.0.0 UG 0 0 0 eth1
[root@localhost network-scripts]#
[root@localhost network-scripts]# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
100.100.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
0.0.0.0 100.100.100.254 0.0.0.0 UG 0 0 0 eth1
[root@localhost network-scripts]#
이후에는 서버 재시작을 하거나, service network restart 명령 이후에도 Default Gateway 설정이
유지되는 것을 확인할 수 있었습니다. :)
댓글 없음:
댓글 쓰기