双网卡linux

双网卡linux

我的/etc/iproute2/rt_tables

255 local
254 main
253 default
0   unspec
1 brain
2 strom

我正在使用下面给出的/etc/network/interfaces

allow-hotplug eth0
iface eth0 inet static
        hwaddress ether 00:10:5a:02:2b:0e
        address 192.168.1.149
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
        dns-nameservers 8.8.8.8 8.8.4.4
        up ip route add 192.168.1.0/24 dev eth0 table brain
        up ip route add default via 192.168.1.1 dev eth0 table brain
        up ip rule add from 192.168.1.149/32 table brain
        up ip rule add to 192.168.1.149/32 table brain

allow-hotplug eth3
iface eth3 inet static
        hwaddress ether 00:15:17:95:61:eb
        address 192.168.10.149
        netmask 255.255.255.0
        network 192.168.10.0
        broadcast 192.168.10.255
        dns-nameservers 8.8.8.8 8.8.4.4
        up ip route add 192.168.10.0/24 dev eth3 table strom
        up ip route add default via 192.168.10.1  dev eth3 table strom
        up ip rule add from 192.168.10.149/32 table strom
        up ip rule add to 192.168.10.149/32 table strom

对于 Linux 机器的两个上行链路 -- 使用源策略路由

对于eth0,一切都很好 - 我可以使用 eth0 ping yahoo.com,浏览也可以, #ping -I eth0 yahoo.com 工作正常。我还可以浏览互联网eth0.

现在,eth3 当我使用时pingeth3我也没有得到回应

ping -I eth3 yahoo.com
PING yahoo.com (72.30.35.10) from 192.168.10.149 eth3: 56(84) bytes of data.
From strom (192.168.10.149) icmp_seq=1 Destination Host Unreachable
From strom (192.168.10.149) icmp_seq=2 Destination Host Unreachable

eth3但当我使用时端口 80 工作正常curl

curl --interface eth3 http://checkip.amazonaws.com/
xxx.xxx.xxx.xxx ( this is a real IP of eth3 for outgoing, which means the traffic flown through eth3 )

当我使用网关 ping 时,eth3 我在本地得到响应

#ping 192.168.10.1
PING 192.168.10.1 (192.168.10.1) 56(84) bytes of data.
64 bytes from 192.168.10.1: icmp_req=1 ttl=64 time=5.53 ms

只有 LAN 外的 pingeth3不起作用--

eth3 LAN 端的 Samba 共享也工作正常

现在 ping 的 tcpdump 已打开eth3

tcpdump -i eth3 

我只看到who-has

14:18:07.747843 ARP, Request who-has 72.30.35.10 tell 192.168.10.149, length 28
14:18:08.745739 ARP, Request who-has 72.30.35.10 tell 192.168.10.149, length 28
14:18:09.745736 ARP, Request who-has 72.30.35.10 tell 192.168.10.149, length 28
14:18:10.763054 ARP, Request who-has 72.30.35.10 tell 192.168.10.149, length 28
14:18:11.761736 ARP, Request who-has 72.30.35.10 tell 192.168.10.149, length 28

我很简单不明白为什么 ping 不适用于传出的互联网世界eth3

我的路由表是

# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 docker0
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.10.0    0.0.0.0         255.255.255.0   U         0 0          0 eth3

我的策略路由是

# ip route show table strom
default via 192.168.10.1 dev eth3
192.168.10.0/24 dev eth3  scope link


#ip route show table brain
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0  scope link

#ip rule show
0:      from all lookup local
32762:  from all to 192.168.1.149 lookup brain
32763:  from all to 192.168.10.149 lookup strom
32764:  from 192.168.1.149 lookup brain
32765:  from 192.168.10.149 lookup strom
32766:  from all lookup main
32767:  from all lookup default

两个 LAN 的 /etc/hosts 条目

192.168.1.149   puppy
192.168.10.149  strom

相关内容