Network-manager, dnsmasq and OpenNIC

Today, a quick how-to on how to:

  • Override nameservers provided by your DHCP server by the ones from https://www.opennicproject.org, when you are using network-manager
  • Use Network-Manager with dnsmasq to speed up DNS resolution

    I assume you are using your Linux machine as a desktop, not a server, and with network-manager.

    Always use OpenNIC name servers

    In /etc/dhcp/dhclient.conf, add this line, this will override DNS provided by your DHCP server:

    supersede domain-name-servers 193.183.98.154, 104.244.72.13;

    You can put several servers separated per commas.

    Restart network-manager, then you can check /etc/resolv.conf file has been written with the OpenNIC nameservers.

    # Generated by NetworkManager
    nameserver 193.183.98.154
    nameserver 104.244.72.13

    You can find the closest name servers to your location here: http://wiki.opennicproject.org/ClosestT2Servers

    Use dnsmasq as local DNS cache

    Easy, install dnsmasq package, then put this in /etc/dnsmasq.d/custom:

    # disable dnsmasq DNS server
    port=0
    # Activate dnsmasq local cache
    listen-address=127.0.0.1

    To inform network-manager than you want to use dnsmasq as local DNS resolver, add this line in the [main] section of /etc/NetworkManager/NetworkManager.conf file:

    [main]
    #(some other conf can be present before this line)
    dns=dnsmasq

    You can now check than /etc/resolv.conf contain this:

    # Generated by NetworkManager
    nameserver 127.0.0.1

    Enjoy !

    Useful links:

    https://wiki.archlinux.org/index.php/Dnsmasq
    ~

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *