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
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
centos6多出一條路由
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
這個是LinuxZeroconfig的結果,通過修改/etc/sysconfig/network,在文件結尾添加即可解決 。
NOZEROCONF=yes