當服務器有兩張網卡時,須要添加路由指定流量進出口優先級centos
1.先設置路由優先級服務器
vi /etc/iproute2/rt_tables 255 local 254 main 253 default 0 unspec 251 SZ 252 HK
2.添加路由centos7
vi /etc/rc.local ip route flush table SZ(SZ表明網卡別名) ip route add default via 192.168.1.1 dev eth0 src 192.168.1.100 table SZ ip rule add from 192.168.1.100 table SZ ip route flush table hk(hk表明網卡別名) ip route add default via 192.168.2.1 dev eth1 src 192.168.2.100 table hk ip rule add from 192.168.2.100 table hk
3.最後執行spa
/etc/rc.local
4.注意centos7要對rc.local添加執行權限code