1

Just so I know.

Whether you use a standalone DHCP server or one embedded in a SOHO router, how does the DHCP server obtain the typical 2 DNS IPs it passes to clients?

My idea is that, when a SOHO router DHCPs its IP address, default gateway etc. from the ISP, it also obtains the DNS server IPs, and it passes them to the SOHO router’s DHCP server so it can pass them to clients. But I must be wrong, as if the DHCP server is a standalone machine, how does it get the IPs for DNS servers? Does it query the ISP? I don't think so, it would have to be connected to the modem in order to send the DORA messages, right? Or do you have to type them manually into the server?

Any insight appreciated.

2 Answers 2

2

Wikipedia explains the concepts in its article Dynamic Host Configuration Protocol (DHCP).

The router is an internet client on the internet network created by the ISP. It is also the server for the local network. The process totally depends on the DHCP request, where the router is a DHCP client on the outer network and a DHCP server for the internal one.

In general, DHCP requests work like this :

enter image description here

Where :

  • DHCPDISCOVER : The client broadcasts looking for a DHCP server.
  • DHCPOFFER : The DHCP server offers an IP address for the client, specifying also the subnet mask, and the IP address of the DHCP server itself.
  • DHCPREQUEST : The client replies with a broadcast message, requesting the offered address, after verifying via ARP request that this address is free to be used.
  • DHCPACK : The server finalizes the negotiations and send all the information required, including a number of DNS servers.

The router starts by using this protocol as the client, and at the end receives its own external IP, the IP of the DHCP server of the ISP, the internet gateway and the DNS servers (normally these are maintained by the ISP in its network).

Any computer in the local network will also use this same exact protocol. But here the router is the server, so it returns a local network IP for the computer, its own IP as the DHCP server and gateway. For the DNS, the router usually passes on the servers it receives from the ISP, but can also sometimes return its own IP instead.

1
  • Great explanation. Super Thanks! Commented Oct 27, 2022 at 16:01
1

Whether you use a standalone DHCP server

A standalone DHCP server typically starts "empty" – you have to configure it for the address pools to offer and you have to configure it for the DHCP lease options to include along with the address. ("DNS servers" is option 6, it's often accompanied by "Domain suffix" option 15.)

For example, the widely used ISC DHCP Server dhcpd on Linux would be configured like this:

subnet 10.147.112.0 netmask 255.255.255.0 {
    range 10.147.112.2 10.147.112.254;
    option routers 10.147.112.1;
    option domain-name-servers 10.147.10.53;
    option domain-name "internal.example.org";
}

(Note how even the "default gateway" has to be specified explicitly!)

The dnsmasq DHCP server is tailored for home use (and sometimes found inside SOHO routers) and can automatically offer the DNS servers that the host OS is configured to use (by reading /etc/resolv.conf), though they can also be listed explicitly:

dhcp-range = 10.147.112.2, 10.147.112.254, 255.255.255.0
dhcp-option = option:domain-name, lan.example.org
dhcp-option = option:dns-server, 10.147.10.53

But as the name suggests, DNS server IP addresses technically are optional information and an address lease could be issued without them – e.g. if setting up an isolated network that doesn't need DNS, you could just not send option 6 in the DHCP leases at all.


Also note that the DNS server information does not have to be obtained from the ISP – any public DNS server has the same access to domain information as any other public DNS server, so you could choose to use a third-party resolver (such as Google's 8.8.8.8) or even run one yourself.

In the (real) examples above, 10.147.10.53 is a local DNS server running ISC BIND (in another subnet of the same network) which resolves domain names without any help from the ISP's resolvers, or any other resolvers for that matter – it directly talks to the authoritative servers of each domain.

Resolving a domain name involves chasing referrals (pointers to another server) starting from the "DNS root" nameservers. The list of root servers changes extremely rarely and most DNS "recursive resolver" software just have the list built-in, meaning that they do the job without needing to detect or provide any server information at all.

So even if you don't know any DNS server addresses to use, all you need is to install any recursive resolver software such as Unbound or ISC BIND on the same system (and make the DHCP server advertise its local IP address) – and you have fully working DNS service.

3
  • Thanks for your answer. What I asked is mainly "how SOHO routers DHCP the DNS servers IPs from the ISP and then pass it over to the LAN clients". Commented Oct 27, 2022 at 16:03
  • You already answered that part in your own post, though. Commented Oct 27, 2022 at 17:08
  • Thanks user1686, you've been a great help in other of my posts too. Commented Oct 28, 2022 at 13:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .