CentOS7永久静态路由需要写到 /etc/sysconfig/network-scripts/route-******
文件中,故在/etc/sysconfig/network-scripts/
下,新建文件名为route-*****
的文件,(****代表网卡名)
比如添加两条静态路由:(网卡的设备名叫eth0)
[root@centos7 ~]# vim /etc/sysconfig/network-scripts/route-eth0
10.15.150.0/24 via 10.10.10.1 dev eth0
10.25.250.0/24 via 10.10.10.1 dev eth0
查看路由表
[root@centos7 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.25.250.0 10.10.10.1 255.255.255.0 UG 0 0 0 eth0
10.10.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
10.15.150.0 10.10.10.1 255.255.255.0 UG 0 0 0 eth0