f22: how to change default gateway via line command
Rick Stevens
ricks at alldigital.com
Tue Jun 9 18:34:57 UTC 2015
On 06/09/2015 12:44 AM, Ed Greshko wrote:
> On 06/09/15 15:26, James Hogarth wrote:
>>
>>
>> On 8 Jun 2015 13:12, "Dario Lesca" <d.lesca at solinos.it <mailto:d.lesca at solinos.it>> wrote:
>>>
>>> Il giorno sab, 06/06/2015 alle 21.43 +0300, Alchemist ha scritto:
>>>> Couple of possible solutions
>>>
>>> Thanks Alchemist, one of that sure probably partially solves my
>>> problem.
>>>
>>> But the question is: Why in f22 (or new version of NetworkManager?) it
>>> has removed the option to change the default gateway via "ip r rep..."
>>> command line, like i do in previous version or all other version of
>>> redhat or centos?
>>>
>>> I thing this is a issue, not a feature.
>>>
>>> Thanks
>>>
>>
>> Think of it this way.
>>
>> You have your network manager configured (via static or dhcp) to have your default route pointed somewhere.
>>
>> NM tries to maintain its configuration so when it notices you've changed the route at the kernel level it doesn't know it's an admin override and fixes what it thinks is a broken setup.
>>
>> On NM based systems instead of using ip route try the nmcli command.
>>
>> Something like this ought to work:
>>
>> nmcli conn mod <connection-profile-name> ipv4.gateway <ip-address-of-gateway>
>>
>> You can see the present configuration NM thinks it should be with:
>>
>> nmcli conn show <connection-profile-name>
>>
>>
>
> Or not....
>
> [root at f22k ~]# nmcli conn mod enp0s3 ipv4.gateway 192.168.1.18
> Error: Failed to modify connection 'enp0s3': ipv4.gateway: gateway cannot be set if there are no addresses configured
>
> FWIW, on this system ....
>
> [root at f22k ~]# ip route sho
> default via 192.168.1.1 dev enp0s3 proto static metric 100
> 192.168.1.0/24 dev enp0s3 proto kernel scope link src 192.168.1.224 metric 100
>
> [root at f22k ~]# nmcli conn show enp0s3 | grep 192.168.1.1
> IP4.GATEWAY: 192.168.1.1
> IP4.DNS[1]: 192.168.1.1
> DHCP4.OPTION[5]: domain_name_servers = 192.168.1.1
> DHCP4.OPTION[8]: dhcp_server_identifier = 192.168.1.1
> DHCP4.OPTION[17]: routers = 192.168.1.1
> DHCP4.OPTION[29]: next_server = 192.168.1.1
>
> I'm not the OP, but I figured I'd test it out anyway.
you have to specify the connection name, not the interface name.
Connection names are shown via "nmcli connection show --active" under
the "NAME" column. On my laptop:
[root at golem4 4.0.4-202.fc21.x86_64]# nmcli connection show --active
NAME UUID TYPE
DEVICE
System p4p1 5dd47203-fffb-671a-4fd0-4cff98347a3b 802-3-ethernet p4p1
virbr0 6220a6b2-8949-40e9-88f2-410ea4bea592 bridge
virbr0
AD e2503203-94ba-40d1-8d39-fc4c8aa6de7f 802-11-wireless
wlan0
virbr0-nic bc0d814c-e3d1-4a80-bc34-495419549610 generic
virbr0-nic
Now that I know I'm interested in "System p4p1":
[root at golem4 4.0.4-202.fc21.x86_64]# nmcli connection show "System p4p1"
connection.id: System p4p1
connection.uuid: 5dd47203-fffb-671a-4fd0-4cff98347a3b
connection.interface-name: p4p1
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.timestamp: 1433874599
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.secondaries:
connection.gateway-ping-timeout: 0
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: full
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: 14:FE:B5:A9:A4:8E
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
ipv4.method: manual
ipv4.dns: xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx
ipv4.dns-search: mydomain.com
ipv4.addresses: { ip = xxx.xxx.xxx.xxx/24, gw =
xxx.xxx.xxx.xxx }
ipv4.routes:
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.never-default: no
ipv4.may-fail: no
ipv6.method: ignore
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.routes:
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: 0 (disabled)
ipv6.dhcp-hostname: --
GENERAL.NAME: System p4p1
GENERAL.UUID: 5dd47203-fffb-671a-4fd0-4cff98347a3b
GENERAL.DEVICES: p4p1
GENERAL.STATE: activated
GENERAL.DEFAULT: yes
GENERAL.DEFAULT6: no
GENERAL.VPN: no
GENERAL.ZONE: --
GENERAL.DBUS-PATH:
/org/freedesktop/NetworkManager/ActiveConnection/7
GENERAL.CON-PATH:
/org/freedesktop/NetworkManager/Settings/21
GENERAL.SPEC-OBJECT: --
GENERAL.MASTER-PATH: --
IP4.ADDRESS[1]: ip = xxx.xxx.xxx.xxx/24, gw =
xxx.xxx.xxx.xxx
IP4.DNS[1]: xxx.xxx.xxx.xxx
IP4.DNS[2]: xxx.xxx.xxx.xxx
IP6.ADDRESS[1]: ip =
xxxx::xxxx:xxxx:xxxx:xxxx/64, gw = ::
(with appropriate stuff obfuscated).
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital ricks at alldigital.com -
- AIM/Skype: therps2 ICQ: 226437340 Yahoo: origrps2 -
- -
- "Very funny, Scotty. Now beam down my clothes." -
----------------------------------------------------------------------
More information about the users
mailing list