linux双网卡双ip配置

在/etc/rc.local里面加上
ip route replace default via 221.6.67.33 dev eth1
ip route replace default via 180.97.81.1 dev eth0
ip route flush table ctc
ip route add default via 180.97.81.1 dev eth0 src 180.97.81.178 table ctc proto static
ip rule add from 180.97.81.178 table ctc
ip route flush table cnc
ip route add default via 221.6.67.33 dev eth1 src 221.6.67.49 table cnc proto static
ip rule add from 221.6.67.49 table cnc

在/etc/iproute2/rt_tables 里面加上

252 cnc
251 ctc

服务器重启,或者网络服务重启,上述的路由规则就失效了,重新启动一下脚本就行了,

如果是ubuntu/debian,系统启动脚本是/etc/rc.local 
如果是RedHat/CentOS,系统启动脚本是/etc/rc.d/rc.local

如果是ubuntu/debian,网络启动脚本是/etc/init.d/networking 
如果是RedHat/centos,网络启动脚本是/etc/rc.d/init.d/network

引用了另个一个博主的内容,这个博主说是的ubuntu系统,基本原理一样,有兴趣可以学习一下,链接如下 :  https://www.cnblogs.com/luckyall/p/6418965.html

猜你喜欢

转载自www.cnblogs.com/guizjiang/p/11418936.html
今日推荐