centos双路ISP(三、持久化)

2016/6/21 14:36 下午 目录  Linux 评论

1、iproute定义的route 和rule持久化

  • 新增路由表

    echo " 201    T1
    202 T2" >> cat /etc/iproute2/rt_tables
    
  • 为br0 br1 创建route规则配置文件

    echo  "
    192.168.199.0/24 dev br0 src 192.168.199.11 table 202
    default via 192.168.199.1 table  202
    " > /etc/sysconfig/network-scripts/route-br0
    
    echo  "
    192.168.1.0/24 dev br1 src 192.168.1.11 table 201
    default 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-br0
    echo  "
    from  192.168.1.11 table T1
    " > /etc/sysconfig/network-scripts/rule-br1
    

2、重启网络检查路由配置情况

systemctl restart network
ip route show table T1
ip route show table T2
ip rule show

3、从外网测试连接成功

centos终于可以像windows一样自动判断来源网卡设定回归的路由

ip route + ip rule实现双ISP接入网络配置
route命令详解
iproute2 策略路由与流量控制笔记
Linux策略性路由应用及分析(iproute2)
ip route 官方手册
iproute2 之 ip命令使用教程手册