How can I force a nameserver resolution using the second nameserver on an ubuntu server

Ahmad asked:

I try to download something from nvidia on a remote server via ssh. Iran is banned by the nvidia website. When I check the server dns, that is:


I know if I could set the dns to google dns ( or then I was able to surf the website and download from it. I tried to change the dns on the server but whatever I do it’s the same as above.

Its the content of /etc/network/interfaces

uto lo
iface lo inet loopback

#auto enth0
iface eth0 inet static

This is the output of ifconfig

eno1      Link encap:Ethernet  HWaddr 34:97:f6:dc:9f:ff  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::c8cd:597a:b384:a22b/64 Scope:Link
          RX packets:2101 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1298 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:891719 (891.7 KB)  TX bytes:237702 (237.7 KB)
          Interrupt:20 Memory:fb200000-fb220000 

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host

I wonder why network id is eno1?! it’s the output of sudo nmcli c

NAME                UUID                                  TYPE            DEVICE 
Wired connection 1  532cfa3a-d61b-4bc4-b516-1dc31a5baead  802-3-ethernet  eno1

Once I changed eth0 to eno1 but then I couldn’t access the server until the file was set back to eth0

I also installed resolvconf and followed instruction of this website

the content of /etc/resolv.conf is preserved but the dns doesn’t change

Yet, I might be able to use the secondary dns to connect a website (using wget or other solutions)

Is it possible, what could I do?

My answer:

It looks like your system is using NetworkManager to manage its connection to the network. This is helpful, because what you want to do needs to be done in NM, and cannot be done in the interfaces file.

You need to modify a NetworkManager setting for your connection to tell it to ignore the DNS servers provided by DHCP so that it will only use your chosen DNS servers:

nmcli c mod "Wired connection 1" ipv4.ignore-auto-dns true

You can then restart the network or the computer. All of your DNS queries should now use your chosen nameservers.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.