I want to remove the DNS currently associated to the device and add a new one using nmcli
So, if I do nmcli device show eth0
I can see
IP4.DNS[1]: 10.0.2.2
If I do sudo nmcli device modify eth0 ipv4.dns "8.8.8.8"
then I can see
IP4.DNS[1]: 10.0.2.2
IP4.DNS[2]: 8.8.8.8
but I want to remove the first one. How can I do it? If i try sudo nmcli device modify eth0 ipv4.dns ""
then the second one (8.8.8.8
) is removed but the first one is still there.
My final goal is to set ONLY 8.8.8.8
(for example...)
EDIT:
I am a bit confused between connection
and device
.
For example, let's say that I had 10.0.2,2
and I had 8.8.8.8
using one of these two commands:
nmcli connection modify netplan-eth0 ipv4.dns 8.8.8.8
nmcli device modify eth0 ipv4.dns 8.8.8.8
Because it seems there is a device and then there is a connection bound to it, so I can modify the dns using one of these two commands.
Now, I can see:
Using nmcli device show
I have in the result
IP4.DNS[1]: 10.0.2.2
IP4.DNS[2]: 8.8.8.8
but using nmcli connection show netplan-eth0
I can see only
ipv4.dns: 8.8.8.8
So, my problem now is that I can easily modify the only dns in the connection, that is 8.8.8.8
using one of the followin command:
nmcli connection modify netplan-eth0 -ipv4.dns 8.8.8.8
nmcli device modify eth0 -ipv4.dns 8.8.8.8
BUT, I don't know how to remove the 10.0.2.2
that is showing only in the device
but not in the connection
.
BTW I did not set manually 10.0.2.2
, I suppose it was taken through dhcp
. And for some motivation this dns is bound only to the device
but not to the connection
.
With these details the problem should be more clear :)
question from:
https://stackoverflow.com/questions/65922054/remove-dns-from-device-using-nmcli