linux7配置静态路由

# nmcli connection edit eth0

===| nmcli interactive connection editor |===

Editing existing '802-3-ethernet' connection: 'eth0'

Type 'help' or '?' for available commands.
Type 'describe [<setting>.<prop>]' for detailed property description.

You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, ipv4, ipv6      
nmcli> set ipv4.routes 192.168.0.0/24 192.168.0.1
nmcli> save
Connection 'eth0' (1f4df442-163b-401d-a5f0-aec1aa3f5286) successfully updated.
nmcli> quit
# nmcli connection down eth0
# nmcli connection up eth0
# nmcli connection show eth0
...
ipv4.routes:                            { ip = 192.168.0.0/24, nh = 192.168.0.1 }
...

其中,eth0为需要添加路由的设备,可以看到,路由已经添加上去了,同时netstat -rn也能看的到
PS.自从centos7开始使用nmcli管理网络,关于静态路由的配置就比较混乱了,而且很难在帮助文档中找到。

Logo

更多推荐