달력

5

« 2025/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'route-eth0'에 해당되는 글 1

  1. 2013.09.13 영구적인 Multi Gateway 설정 Centos
2013. 9. 13. 21:36

영구적인 Multi Gateway 설정 Centos Linux2013. 9. 13. 21:36

Linux에 랜카드가 두장이상일 때 

랜카드별로 각각 외부로 나가는 gateway가 필요할 경우가 생겼다.

- 다수의 서버로 시스템을 구성시 공인아이피로는 이미지전용이나 파일서버로 사용할때

나머지(http, https, ssh 는 공유기를  거쳐 서비스를 할경우가 이런경우다.

ip route 등의 명령어로 세팅하는 경우 영구 저장되지 않기때문에

서비스에 적용할 경우 리부팅하면 환장하는경우가 발생한다.

다음을 참고하여 영구히 적용하도록 한다.


A(eth0) : 인터넷에 연결되어 있으며 공인아이피를 가짐 (gw: 222.222.222.1)

B(eth1): 공유기(또는 스위치) 에 연결되어있으며, private 또는 다른 네트웍대에 연결되어 있다고 가정. (gw: 192.168.0.1)

[root@centos ~]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 * 255.255.255.0 U 0 0 0 eth1 222.222.222.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 1002 0 0 eth0 link-local * 255.255.0.0 U 1003 0 0 eth1 default 22.222.222.1 0.0.0.0 UG 0 0 0 eth0
[root@blog1 ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:1B:78:A3:3F:BE inet addr:222.222.222.100 Bcast:222.222.222.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:367 errors:0 dropped:0 overruns:0 frame:0 TX packets:211 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:53333 (52.0 KiB) TX bytes:150417 (146.8 KiB) Interrupt:16 eth1 Link encap:Ethernet HWaddr 00:1B:78:A3:3F:BF inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2270 errors:0 dropped:0 overruns:0 frame:0 TX packets:27 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:151511 (147.9 KiB) TX bytes:4721 (4.6 KiB) Interrupt:17 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

[root@blog1 ~]# cat /etc/iproute2/rt_tables # # reserved values # 아래 붉은색 부분에 public, private 이름의 테이블을 추가한다. 255 local 254 main 253 default 0 unspec 200 public 201 private # # local # #1 inr.ruhep

//다음 4개의 파일 추가 한다, [root@blog1 ~]# cat /etc/sysconfig/network-scripts/route-eth0 222.222.222.0/24 dev eth0 src 222.222.222.100 table public default via 211.241.227.254 dev eth0 table public [root@blog1 ~]# cat /etc/sysconfig/network-scripts/route-eth1 192.168.0.0/24 dev eth1 src 192.168.0.101 table private default via 192.168.0.1 dev eth1 table private
[root@blog1 ~]# cat /etc/sysconfig/network-scripts/rule-eth0 from 222.222.222.100 table public to 222.222.222.100 table public [root@blog1 ~]# cat /etc/sysconfig/network-scripts/rule-eth1 from 192.168.0.101/24 table private to 192.168.0.103 table private [root@blog1 ~]# ip route flush cache
[root@blog1 ~]# service network restart
(ifdown eth0; ifup eth0 등으로 재시작 안하고 확인 가능)

//적용 및 확인
[root@blog1 ~]# ip route list 192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.101 222.222.222.0/24 dev eth0 proto kernel scope link src 222.222.222.100 169.254.0.0/16 dev eth0 scope link metric 1002 169.254.0.0/16 dev eth1 scope link metric 1003 default via 222.222.222.1 dev eth0 
[root@blog1 ~]# ip rule list 0: from all lookup local 32762: from all to 192.168.0.101 lookup private 32763: from 192.168.0.101/24 lookup private 32764: from all to 222.222.222.100 lookup public 32765: from 222.222.222.100 lookup public 32766: from all lookup main 32767: from all lookup default

[root@blog1 ~]# traceroute -s 192.168.0.101 yahoo.com
[root@blog1 ~]# traceroute -s 222.222.222.100 yahoo.com

위 두개의 결과를 비교하여 잘 적용했는지 확인할것!





:
Posted by basecode