Loading

CentOS7添加永久静态路由

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
posted @ 2019-08-17 16:06  Outsrkem  阅读(17935)  评论(1编辑  收藏  举报