我想确保所有发往 172.16.60.62 的 IP 流量都使用 eth6。请提供完整的命令,因为我的 Linux 技能已经生疏了。主机运行的是 Ubuntu Precise 12.04
user@host:~$ ifconfig eth3
eth3 Link encap:Ethernet HWaddr 00:e0:81:72:fe:c9
inet addr:172.16.60.122 Bcast:172.16.60.255 Mask:255.255.255.0
inet6 addr: fe80::2e0:81ff:fe72:fec9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:128500 errors:0 dropped:0 overruns:0 frame:0
TX packets:29082 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:67524823 (67.5 MB) TX bytes:2217634 (2.2 MB)
Interrupt:71 Base address:0x6000
user@host:~$ ifconfig eth6
eth6 Link encap:Ethernet HWaddr 00:60:dd:47:81:35
inet addr:172.16.60.61 Bcast:172.16.60.255 Mask:255.255.255.0
inet6 addr: fe80::260:ddff:fe47:8135/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:9000 Metric:1
RX packets:109610 errors:0 dropped:0 overruns:0 frame:0
TX packets:109388 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10785630 (10.7 MB) TX bytes:10754350 (10.7 MB)
Interrupt:70
user@host:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.16.60.1 0.0.0.0 UG 0 0 0 eth3
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth6
172.16.60.0 0.0.0.0 255.255.255.0 U 1 0 0 eth6
172.16.60.0 0.0.0.0 255.255.255.0 U 1 0 0 eth3
答案1
您可以为该特定 IP 地址添加静态路由,将其发送到您想要的任何位置:
# ip route add 172.16.60.62/32 dev eth6
顺便说一句,“ifconfig”和“route”在 Linux 上已被弃用;您最好使用“ip”:
$ ip address show
$ ip link show
$ ip route show
您可以缩写这些命令以使事情变得更快。ip a s
等等。