centos7-添加双网卡

操作系统版本

CentOS Linux release 7.7.1908

配置双网关

/etc/iproute2/rt_tables文件中增加两个新的路由表

252 e1   #自定义, 不重复即可
251 e0

手动添加静态路由, 从哪里进来就从哪里出去, 本机出去的走默认网关

ip route flush table b1
ip route add default via 200.198.66.1 dev br1 src 200.198.66.2 table b1
ip route add 127.0.0.0/8 dev lo table b1
ip rule add from 200.198.66.2 table b1
ip route flush table b2
ip route add default via 192.168.66.1 dev br2 src 192.168.66.2 table b2
ip route add 127.0.0.0/8 dev lo table b2
ip rule add from 192.168.66.2 table b2

默认网关可以在/etc/sysconfig/network设置

cat /etc/sysconfig/network
# Created by anaconda
GATEWAY=192.168.66.1

注意: 重启失效 !!!!
可以写到rc.local下

原文链接:https://blog.csdn.net/l1028386804/article/details/77455929

猜你喜欢

转载自www.cnblogs.com/peitianwang/p/12173172.html