f22: how to change default gateway via line command

Rick Stevens ricks at alldigital.com
Thu Jun 11 17:00:34 UTC 2015


On 06/11/2015 02:42 AM, Dario Lesca wrote:
> Il giorno mar, 09/06/2015 alle 15.50 -0700, Rick Stevens ha scritto:
>> I think you have to change the method to "manual", then set the IP
>> address and route:
>>
>>        sudo nmcli conn mod p6p1 ipv4.method manual ipv4.address
>> 192.168.61.80/24 ipv4.gateway 192.168.61.254
>>
>> The "auto" method for an ethernet port means DHCP.
>
> Ok, this can work, but I must setup also ipv4.dns  and ipv4.dns-search,
> but this method is similar an more simple to configuring a static new
> profile in NM. And this is not want to do.
>
> What I want to do, is a setting in NetworkManager to use the IP and DNS
> via DHCP and default gateway set by me, for test some time other router
> into network.
> I could not set this kind of configuration via the configuration panel
> of NetworkManager.
>
> Someone can help me to do that?

Not sure about this, but you could try the "Automatic (DHCP)" option
under the IPV4 settings, then click "Routes..." and add a route with
address 0.0.0.0, netmask 0.0.0.0, gateway of your choosing and a metric
of 1. Also make sure the "Ignore automatically obtained routes" checkbox 
is ticked. I believe that now becomes your default gateway.

> But now it appeared a new problem, the IP set with nmcli, remain set
> also when I have put the ipv4.method to auto, disconnect then reconnect
> the cabled and restart NetworkManager.
>
> it seems that the change is permanent, and now I do not know how to
> delete it.
>
> Can someone help me?

Try the command:

	sudo nmcli conn show --active

and verify that the correct profile is being used. If it is, then:

	sudo nmcli conn show <profile-name>

and look carefully at the data. Verify that ipv4.method is set to auto.
If it is, then you may have to do a full NM restart:

	sudo systemctl restart NetworkManager
----------------------------------------------------------------------
- Rick Stevens, Systems Engineer, AllDigital    ricks at alldigital.com -
- AIM/Skype: therps2        ICQ: 226437340           Yahoo: origrps2 -
-                                                                    -
-        "And on the seventh day, He exited from append mode."       -
----------------------------------------------------------------------


More information about the users mailing list