13

Every 6 months or so I cannot access the DNS on whatever router I'm using. usually have to add the nameserver by hand to the /etc/resolv.conf file. I've tried adding Google free DNS to the file and it changes nothing. What can I do to not have to manually change the file each time I go to different coffee shop?

  • Which dhcp client do you use? There should be a configuration option to ignore the DNS provided by dhcp. – casey Jul 25 '14 at 1:18
  • I'm using Network-Manager not ifup. – John Coder Jul 25 '14 at 1:25
22

You can add the following line to /etc/dhcp/dhclient.conf:

prepend domain-name-servers <working DNS IP(s) here>;

This adds the DNS IP address(es) you specify before that/those provided by the DHCP. If you would like to add it/them after the address(es) provided by the DHCP, just use

append domain-name-servers <working DNS IP(s) here>;

If, instead you would like to ignore the DNS address(es) provided by the DHCP altogether, use

supersede domain-name-servers <working DNS IP(s) here>;
| improve this answer | |
  • 1
    @casey Yes. Please see the update. – Joseph R. Jul 25 '14 at 1:27
  • not sure I had to do this from my windoze box since I don't have DNS capabilities at all. I can ping the quad-notation just no nameserver recognition – John Coder Jul 25 '14 at 1:28
  • @JohnCoder I'm not sure I understand what you're saying. Please clarify... – Joseph R. Jul 25 '14 at 1:29
  • I can ping for instance the google dns 8.8.8.8 but I cannot ping goggle.com on the Linux box but I'm posting this from my windows box since I cannot access the nameserver from my Linux box. I'll reboot and see. – John Coder Jul 25 '14 at 1:33
  • @JohnCoder What do you get with host google.com 8.8.8.8? – Joseph R. Jul 25 '14 at 1:39
4

You can tell NetworkManager to ignore the DHCP provided DNS servers, by putting this in the network's config file (/etc/NetworkManager/system-connections/my-essid if saved to the system).

The important bit is ignore-auto-dns=true

[ipv4]
ignore-auto-dns=true
dns=8.8.8.8;
method=auto
| improve this answer | |
  • 2
    Is there any way to enforce this setting on all connections? I mean, can I set this as a default, so when I connect to another wifi, it will automatically ignore its DHCP's DNS? – Vojtech Kane Apr 29 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.