centos 7 增加永久静态路由

1 在 /etc/sysconfig/network-scripts/ 目录下添加route-eth3,eth3为实际网卡名称。
[root@compute1 ~]# cat /etc/sysconfig/network-scripts/route-eth3
121.14.46.1/32 via 10.160.20.129 dev eth3
2 重启eth3
[root@compute1 ~]# ifdown eth3 && ifup eth3
成功断开设备 "eth3"。
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/11)
3 查看路由表
[root@compute1 ~]# ip route
default via 10.160.20.1 dev eth0 proto static metric 100
10.160.20.0/26 dev eth0 proto kernel scope link src 10.160.20.23 metric 100
10.160.20.128/26 dev eth3 proto kernel scope link src 10.160.20.131 metric 103
121.14.46.1 via 10.160.20.129 dev eth3 proto static metric 103
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
备注:生产环境如果不想重启添加路由的网卡,可以先编辑route-eth3文件,加一条临时路由生效,下次重启服务器,系统自然会去读取route-eth3文件,不需要再添加。
[root@compute1 ~]# ip route add 121.14.46.1/32 dev eth3 via 10.160.20.129


原文地址:https://www.cnblogs.com/cloud-datacenter/p/12357293.html