안녕하세요. 제 리눅스에 랜카드가 2개 있는데요

eth0는 192.168.10.0/24 네트워크이고
eth1은 192.168.1.0/24 네트워크에 연결되어 있습니다.

외부로 나가는 패킷을 eth0를 통해서 나가도록 설정하고 싶은데

아래처럼 default gateway가 eth1로 설정되어서 eth1로 나가고 있습니다.

[root@fujitsu ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
192.168.10.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 192.168.1.1 0.0.0.0 UG 0 0 0 eth1

그래서 아래처럼 명령을 내렸습니다.



$ route add default gw 192.168.10.1 eth0

결과는 아래와 같습니다.

[root@fujitsu ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
192.168.10.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 192.168.10.1 0.0.0.0 UG 0 0 0 eth0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth1

이렇게 했는데.. 여전히 외부로 나가는 패킷이 eth1(192.168.1.1)을 통해 전송됩니다.

eth0를 통해서 외부로 나가도록 할수는 없을까요?

감사합니다.

 



참조 : http://sinun.tistory.com/25

default 라우팅

default 라우팅 원래있던걸 지워주세요

언제나 삽질 - [url=http://http://tisphie.net/typo/]http://tisphie.net/typo/[/url]
프로그래밍 언어 개발 - http://langdev.net[/url]

언제나 삽질 - http://tisphie.net/typo/
프로그래밍 언어 개발 - http://langdev.net

또는 gateway eth0의

또는 gateway eth0의 metric을 높여 버리시면 eth1이 우선이 됩니다.

답변감사합니다.

=====================

두분 답변 감사합니다. ^^

메트릭값을 높여서 처리할 수도 있겠지만

default gw는 한개만 있는게 정상일것 같은 생각이 드네요.

IP 받아올때 default gw를 모두 지워버린 후
다시 설정하는 식으로 변경하는게 좋을 것 같습니다.

dhclient 로 동적으로 IP를 받아오는 건데...
ps 해보니깐 아래처럼 나오네요

$ ps -ef 
.... 생략
/sbin/dhclient -d -sf /usr/libexec/nm-dhcp-client.action -pf /var/run/dhclient-eth1.pid -lf /var/lib/dhclient/dhclient-eth1.lease -cf /var/run/nm-dhclient-eth1.conf eth1
.... 생략

IP를 받아온 후에 실행되는 스크립트가 /usr/libexec/nm-dhcp-client.action 이네요
근데 스크립트 파일이 아니라.. 바이너리파일이네요

죄송합니다만.. dhclient 실행 옵션은 어디서 조정하는지.. 알 수 있을까요?

nm-dhcp-client.action이 무슨일을 하는지도 모르겠구..에휴

=====================

dhclient.conf 에서

dhclient.conf 에서 조정할 수 있습니다. eth1쪽에 router정보를 요청하지 않으면 되겠네요.

man dhclient.conf 참조.

언제나 삽질 - [url=http://http://tisphie.net/typo/]http://tisphie.net/typo/[/url]
프로그래밍 언어 개발 - http://langdev.net[/url]

언제나 삽질 - http://tisphie.net/typo/
프로그래밍 언어 개발 - http://langdev.net

답변 감사합니다.

=====================

답변감사합니다.
좋은 하루 되세요

=====================

 

출처 :https://kldp.org/node/118511


+ Recent posts