假定主机的网卡1的IP地址为:219.223.244.233/21,网卡2的IP地址为:219.223.242.216/21单网为:219.223.240.1(这里21表示网络地址)
首先,增加网关地址:
route add -net 219.223.240.0 netmask 255.255.248.0 gw 219.223.240.1
其次,修改/etc/iproute2/rt_tables,添加内容如下:
252 net2
251 net3
#/etc/rc.local添加原路返回路由,内容如下:
ip route flush table net2
ip route add default via 219.223.240.1 dev eth0 src 219.223.244.233 table net2
ip rule add from 219.223.244.233 table net2
ip route flush table net3
ip route add default via 219.223.240.1 dev eth1 src 219.223.242.216 table net3
ip rule add from 219.223.242.216 table net3
最后,重启电脑即可