Menu

目录

配置静态路由

  • 使用nmcli命令为网络连接配置静态路由,使用命令如下:

    # nmcli connection modify eth0 +ipv4.routes "192.168.122.0/24 10.10.10.1"
    
  • 使用编辑器配置静态路由,使用如下命令:

    # nmcli con edit type ethernet con-name ens3
    ===| nmcli interactive connection editor |===
    Adding a new '802-3-ethernet' connection
    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, ipv4, ipv6, dcb
    nmcli> set ipv4.routes 192.168.122.0/24 10.10.10.1
    nmcli>
    nmcli> save persistent
    Saving the connection with 'autoconnect=yes'. That might result in an immediate activation of the connection.
    Do you still want to save? [yes] yes
    Connection 'ens3' (704a5666-8cbd-4d89-b5f9-fa65a3dbc916) successfully saved.
    nmcli> quit