linux 多网卡静态路由配置

linux 多网卡静态路由配置:
1、etc/sysconfig/ 目录下编辑static-routes文件,没有则新建
文件内写入路由命令
格式:
普通路由:

any -net [网段/子网掩码(172.16.100.0/24)] gw [网关]

默认路由:

any default gw [网关] dev [网卡ID]

2、etc/init.d/network 文件中找到以下语句(大约在133行)

 # Add non interface-specific static-routes.
        if [ -f /etc/sysconfig/static-routes ]; then
           grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
              /sbin/route add **-$args**
           done
        fi

修改成

 # Add non interface-specific static-routes.
        if [ -f /etc/sysconfig/static-routes ]; then
           grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
              /sbin/route add **$args**
           done
        fi

*******(去掉‘-’)
保存
3、执行命令 service network restart 或者 reboot

猜你喜欢

转载自blog.csdn.net/weixin_42119188/article/details/87916705