nmcli does not accept 0.0.0.0/0 for the default gateway in ipv4.gateway
Environment
- Red Hat Enterprise Linux 7
Issue
- I need to modify the default gateway via nmcli but I receive error about invalid gateway address.
Resolution
- The nmcli utility does not support using 0.0.0.0/0 for the default gateway in ipv4.gateway.
- To work around this problem, you may create separate routes for both the 0.0.0.0/1 and 128.0.0.0/1 subnets, which covers also the full IPv4 address space.
Root Cause
- The nmcli utility does not support using 0.0.0.0/0 for the default gateway in ipv4.gateway.
Diagnostic Steps
# nmcli con modify ens3 ipv4.gateway 192.168.11.1
Error: Failed to modify connection 'ens3': ipv4.gateway: gateway cannot be set if there are no addresses configured
# nmcli con modify ens3 ipv4.gateway "0.0.0.0/0 192.168.11.1"
Error: failed to modify ipv4.gateway: invalid gateway address '0.0.0.0/0 192.168.11.1'.
# nmcli con modify ens3 +ipv4.routes "0.0.0.0/1 192.168.11.1, 128.0.0.0/1 192.168.11.1"
# nmcli dev reapply ens3
Connection successfully reapplied to device 'ens3'.
# ip route
0.0.0.0/1 via 192.168.11.1 dev ens3 proto static metric 100
128.0.0.0/1 via 192.168.11.1 dev ens3 proto static metric 100
192.168.11.0/24 dev ens3 proto kernel scope link src 192.168.11.179 metric 100
SBR
Product(s)
Components
Category
Tags
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.