Announcement

Collapse
No announcement yet.

How to remove the DNS server received from DHCP in dnsmasq?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to remove the DNS server received from DHCP in dnsmasq?

    I'd like to remove the DNS server received from DHCP, so dnsmasq don't send DNS queries to it.

    I have defined server=XXXX directives in /etc/NetworkManager/dnsmasq.d/my-servers, but it only adds these servers to the default DNS server received from my DHCP server (the ADSL router).

    Is there a way to tell dnsmasq not to ask the DNS server received from DHCP?

    #2
    If you select to use a static IP instead of DHCP and you specify the DNS servers, dhclient will not run and your /etc/resolv.conf file will only be populated by the DNS servers you specify. If you prefer to use DHCP, then your list will contain the servers that are in your router. A couple of ways to accomplish what you want to do, first, and easiest, is to change the DNS servers in your router. The second method, which I have not tried, but should work is to edit the /etc/dhcp/dhclient.conf file. Change it from this:
    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers,
    dhcp6.domain-search, dhcp6.fqdn,
    dhcp6.name-servers, dhcp6.sntp-servers;


    To this.

    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-search, host-name,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers,
    dhcp6.domain-search, dhcp6.fqdn,
    dhcp6.name-servers, dhcp6.sntp-servers;


    If you try the second method let me know if it works.

    Comment


      #3
      Thanks Detonate.
      First option cannot be done in my router; there's no option for changing the DNS servers. It uses the DNS servers received from the ISP and cannot be changed.
      I've just tried second option, but dnsmasq keeps using the DNS server received from DHCP. It's seems that the domain-name-servers are still received even if not requested in the DHCP conf file.
      I think that my only option is to set static IPs in all devices.
      Thanks anyway for your help.

      Comment


        #4
        Solution found! After you pointed me to the dhclient.conf file, I read the man page and found the "supersede" directive.
        The line "supersede domain-name-servers <ip-address>, <ip-address>, <ip-address>;" made the trick.
        I've inserted this line after the "request" line. Not sure if it makes any difference but just in case.

        Comment


          #5
          Good!! I'm making a note of that for future reference. Man pages to the rescue again.

          Comment

          Working...
          X