配置静态路由

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

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

    1. # nmcli con edit type ethernet con-name enp3s0
    2. ===| nmcli interactive connection editor |===
    3. Adding a new '802-3-ethernet' connection
    4. Type 'help' or '?' for available commands.
    5. Type 'describe [<setting>.<prop>]' for detailed property description.
    6. You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, ipv4, ipv6, dcb
    7. nmcli> set ipv4.routes 192.168.122.0/24 10.10.10.1
    8. nmcli>
    9. nmcli> save persistent
    10. Saving the connection with 'autoconnect=yes'. That might result in an immediate activation of the connection.
    11. Do you still want to save? [yes] yes
    12. Connection 'enp3s0' (1464ddb4-102a-4e79-874a-0a42e15cc3c0) successfully saved.
    13. nmcli> quit