在/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
重启服务器或者重新启动脚本 sh /etc/rc.local ,如何配置错误会有报错,按照报错即可
服务器重启,或者网络服务重启,上述的路由规则就失效了,重新启动一下脚本就行了,
如果是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
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有