On Tue, 2021-12-14 at 23:53 +0100, Juan A. Rubio via networkmanager-
list wrote:
> Hello,
> 
> I'm using Network Manager v1.22.16
> 
> I've got an eth0 connection profile configured for DHCP ([ipv4] ->
> method=auto)
> 
> When the connection profile is enabled, two DNS servers are received
> on that particular interface, e.g.:
> 
> $ nmcli dev show eth0
> ...
> IP4.DNS[1]:                             10.27.30.201
> IP4.DNS[2]:                             10.27.30.202
> ...
> 
> All good.
> 
> Let's say that now I want to override the DNS server list on that
> interface and remove those two DNS servers to add my own DNS server,
> e.g. I want this scenario:
> 
> $ nmcli dev show eth0
> ...
> IP4.DNS[1]:                             10.27.30.203
> ...
> 
> Is there a way to do this with nmcli or the DBUS apis?
> 
> Thanks in advance
> Juan

Hi,


NetworkManager is all about configuring profiles ("connections") and
activating them.

Hence, you configure the corresponding profile with the DNS setting.

- See all profiles with `nmcli connection`.
- See the setting of a profile with `nmcli connection show "$PROFILE"`.
- Modify a profile with `nmcli connection modify "$PROFILE" ipv4.dns 8.8.8.8 
ipv4.ignore-auto-dns yes`.
- (Re-)Activate the profile with `nmcli connection up "$PROFILE"`.
- See activated devices with `nmcli device`

See `man nm-settings` or `man nm-settings-nmcli`.


nmcli only talks to the public D-Bus API. So of course all these steps
could also be done by using the D-Bus API directly.


best,
Thomas

_______________________________________________
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to