对于一个 IP 地址(aaa.bb.cd),我需要通过 eth1 而不是 eth0 进行连接(eth0 是默认值,并且应该保持默认值,但我认为在添加 eth1 之后情况并非如此)。
最后一条规则是我自己使用命令route add -host 172.27.4.213 dev eth1
<- 添加了的,我猜这也是不正确的。
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
10.0.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-2eeb687f709e
172.19.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-0971950c62b2
172.20.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-c4f8472e3ea8
172.21.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-197f22a151b6
172.22.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-d1df5bfeb2d6
172.24.0.0 0.0.0.0 255.255.0.0 U 0 0 0 br-e00c82e13142
aaa.bb.c.d 0.0.0.0 255.255.255.255 UH 0 0 0 eth1
$ ip a show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:b5:7d:7b brd ff:ff:ff:ff:ff:ff
inet 10.0.0.27/16 brd 10.0.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feb5:7d7b/64 scope link
valid_lft forever preferred_lft forever
$ ip a show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:0c:29:b5:7d:85 brd ff:ff:ff:ff:ff:ff
inet 10.0.1.170/16 brd 10.0.255.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:feb5:7d85/64 scope link
valid_lft forever preferred_lft forever
/etc/网络/接口
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 10.0.0.27
netmask 255.255.0.0
gateway 10.0.0.1
dns-nameservers 10.0.0.2
auto eth1
allow-hotplug eth1
iface eth1 inet dhcp