为br0 br1 创建route规则配置文件
echo "192.168.199.0/24 dev br0 src 192.168.199.11 table 202default via 192.168.199.1 table 202" > /etc/sysconfig/network-scripts/route-br0echo "192.168.1.0/24 dev br1 src 192.168.1.11 table 201default via 192.168.1.1 table 201" > /etc/sysconfig/network-scripts/route-br1
创建rule规则文件
echo "from 192.168.199.11 table T2" > /etc/sysconfig/network-scripts/rule-br0echo "from 192.168.1.11 table T1" > /etc/sysconfig/network-scripts/rule-br1
重启网络检查路由配置情况
systemctl restart networkip route show table T1ip route show table T2ip rule show
从外网测试连接成功
centos终于可以像windows一样自动判断来源网卡设定回归的路由 route命令的缺陷route命令创建的路由表相当于,iproute2中的main路由表,只能设置一个网关,会根据default网关的添加顺序及metric权重值来取做唯一的网关,一般情况下最后添加的及metric最小的默认路由生效