Linux 通过辅助接口路由所有互联网流量

Linux 通过辅助接口路由所有互联网流量

鉴于 ifconfig 的以下输出,我希望所有传出流量都来自 bond1:1 而不是默认的 bond1 接口,我该如何实现这一点?

bond1     Link encap:Ethernet  HWaddr 00:25:90:2a:db:6f
      inet addr:15.23.88.181  Bcast:15.23.88.183  Mask:255.255.255.248
      inet6 addr: fe80::225:90ff:fe2a:db6f/64 Scope:Link
      UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
      RX packets:1714059 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1342213 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:159624075 (159.6 MB)  TX bytes:397807364 (397.8 MB)

bond1:1   Link encap:Ethernet  HWaddr 00:25:90:2a:db:6f
      inet addr:15.23.72.200  Bcast:15.255.255.255  Mask:255.255.255.255
      UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

bond1:2   Link encap:Ethernet  HWaddr 00:25:90:2a:db:6f
      inet addr:15.23.72.201  Bcast:15.255.255.255  Mask:255.255.255.255
      UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1



root@service:/etc/nginx/sites-enabled# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
15.23.88.176    0.0.0.0         255.255.255.248 U     0      0        0 bond1
10.54.22.192    0.0.0.0         255.255.255.192 U     0      0        0 bond0
10.0.0.0        10.54.22.193    255.0.0.0       UG    0      0        0 bond0
0.0.0.0         15.23.88.177    0.0.0.0         UG    100    0        0 bond1


/etc/network/interfaces

auto bond1
iface bond1 inet static
pre-up /usr/sbin/ethtool -s bond1 speed 1000 duplex full autoneg on
post-up ifenslave bond1 eth1 eth3
pre-down ifenslave -d bond1 eth1 eth3
bond-slaves none
bond-mode 4
bond-miimon 100
bond-downdelay 0
bond-updelay 0
bond-lacp-rate fast
bond-xmit_hash_policy 1
address 15.23.88.181
netmask 255.255.255.248
gateway 15.23.88.177

auto bond1:1
iface bond1:1 inet static
address 15.23.72.200
netmask 255.255.255.255

auto bond1:2
iface bond1:2 inet static
address 15.23.72.201
netmask 255.255.255.255

我正在使用 Ubuntu,如能得到任何帮助我将非常感激。

答案1

在bond1下的/etc/network/interfaces中添加:

发布 /sbin/ip 路由通过 15.23.88.177 添加默认 dev bond1 src 15.23.72.200

相关内容