set dns servers permanently

Discussion in 'all things UNIX' started by lurningcerv, Nov 26, 2014.

  1. lurningcerv

    lurningcerv Registered Member

    Joined:
    Dec 27, 2011
    Posts:
    87
    How can I set the dns servers permanently in Linux? "Permanently" means so that they cannot be changed by my ISP or anyone else. I ask this question because I am having many delays in connecting to websites. I think that maybe the DNS server that is being used on my connection gives low priority to requests from users that run through proxies, which I do sometimtes. I'm hoping that maybe I can find a dns server that does not do that. But, if I can find such a DNS server(s), I'm going to have to be able to force the use of that server.
     
  2. fblais

    fblais Registered Member

    Joined:
    Jul 31, 2008
    Posts:
    836
    Location:
    Québec, Canada
    Set the DNS server address in your router?
     
  3. mirimir

    mirimir Registered Member

    Joined:
    Oct 1, 2011
    Posts:
    6,028
    If you're using Network Manager, go to the "IPv4 Settings" tab, and change "Automatic (DHCP)" to "Automatic (DHCP) addresses only". Then specify the DNS server(s) that you want to use. If you're not using Network Manager, just edit "/etc/resolv.conf" and add "nameserver w.x.y.z" lines. You can also specify DNS servers in your LAN router, but then all machines on LAN will use them.
     
  4. lurningcerv

    lurningcerv Registered Member

    Joined:
    Dec 27, 2011
    Posts:
    87
    Thanks to those who answered. MirMir, I tried your solution, or at least one of them. We'll see how it works.
     
  5. Gitmo East

    Gitmo East Registered Member

    Joined:
    Jul 28, 2013
    Posts:
    106
    As Mirmir said, just open /etc/resolv.conf as root and replace your ISP's nameservers with your own DNS.
     
  6. mirimir

    mirimir Registered Member

    Joined:
    Oct 1, 2011
    Posts:
    6,028
    Unless you're using Network Manager, which will overwrite resolv.conf :(

    In that case, just do what I said in Network Manager.
     
  7. Gitmo East

    Gitmo East Registered Member

    Joined:
    Jul 28, 2013
    Posts:
    106
    Thanks,
    I never realized this was the case, I'm running OpenSUSE 13.2 Gnome and only connect online via a VPN. I use AirVPN so I've imported the .ovpn config files directly into Network Manager. I was seeing DNS leaks until editting resolv.conf, but nothing since.
    I have also used the Network Manager method on previous installs/distros with successs.
     
  8. lotuseclat79

    lotuseclat79 Registered Member

    Joined:
    Jun 16, 2005
    Posts:
    5,094
    In order to modify the DNS servers in your router without the ISP changing them, you will also need to modify the admin password on your router in order to prevent the ISP from changing them back to their own DNS servers.

    -- Tom
     
Loading...