linux route

当服务器有两张网卡时,须要添加路由指定流量进出口优先级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

相关文章
相关标签/搜索