DHCP gives a client everything it needs to be on the network: an IP address, a subnet mask, a default gateway and the addresses of its DNS servers. DNS then does the next job, turning names like example.com into the IP addresses the client actually connects to, using the DNS server DHCP handed it.
The two services are separate protocols run by different servers, but they depend on each other in a fixed order. A client cannot look up a name until it has an address and knows which DNS server to ask, and DHCP is what supplies both.
What each service does
| DHCP | DNS | |
|---|---|---|
| Question it answers | "What address and settings should I use on this network?" | "What IP address belongs to this name?" |
| When it runs | When a device joins a network, then again at each lease renewal | Each time an application needs to reach a name that isn't cached |
| Who answers | A DHCP server, usually the router at home | A DNS resolver, such as the router, a company server or a public resolver |
| What it returns | Address, mask, gateway, DNS server list, lease time | The record for the name, usually an IP address |
For the detail of each protocol, see what DHCP is and how DNS works. This article covers how they hand off to each other.
Step 1: DHCP configures the client
A new device has no IP address, so it cannot be sent anything directly. RFC 2131 describes how it starts: "The client broadcasts a DHCPDISCOVER message on its local physical subnet." A DHCP server replies with an offer, the client requests that offer, and the server acknowledges it. The reply carries the address plus a set of numbered options defined in RFC 2132. Three of them matter for connecting:
- Option 1, Subnet Mask. Tells the client which addresses are on its own network and which must go through a router.
- Option 3, Router. RFC 2132 says it "specifies a list of IP addresses for routers on the client's subnet". The first usable one becomes the default gateway, the exit toward everything outside the local network.
- Option 6, Domain Name Server. A list of DNS servers the client can use. RFC 2132 says "Servers SHOULD be listed in order of preference", so the client tries the first one first.
Option 15, Domain Name, is related. RFC 2132 describes it as "the domain name that client should use when resolving hostnames via the Domain Name System". That is what lets you type a short hostname such as printer and have the client append the network's domain before asking DNS.
Step 2: DNS resolves names using that configuration
Once the client has an address, it can send packets. When you open a website, the application asks the operating system's resolver for the name's address. RFC 1034 defines the roles: "RESOLVERS are programs that extract information from name servers in response to client requests", and name servers "hold information about the domain tree's structure and set information". RFC 1034 also says "Resolvers must be able to access at least one name server". On a DHCP client, that starting name server address comes from option 6.
The sequence for a typical page load looks like this:
- The client joins the network and gets its address, gateway and DNS server list from DHCP.
- You enter
example.com. The client checks its local DNS cache first. - If the name isn't cached, the client sends a query to the first DNS server from the DHCP lease. That server answers from its own cache or does the lookup on the client's behalf.
- The client now has an IP address for the name. Because that address is outside the local subnet, it sends the packets to the default gateway from option 3.
Every step uses something DHCP provided. Without the address, nothing can be sent. Without the gateway, nothing leaves the local network. Without a DNS server, names can't be resolved, even though the connection works.
Where the home router fits
On a typical home network, one box does all of this. The router is the DHCP server, the default gateway and the DNS server the lease points to. It usually forwards DNS questions it can't answer to the provider's resolvers or to whichever public ones you set. That is why the example below shows one address on three lines. You can change which DNS servers clients get, either in the router's DHCP settings or on a single device; see how to change the DNS server on Windows.
How to see what DHCP gave your computer
On Windows, run this in Command Prompt or PowerShell. Microsoft's documentation says /all "displays the full TCP/IP configuration for all adapters".
ipconfig /all
Example output for one adapter (addresses changed, lines trimmed):
DHCP Enabled. . . . . . . . . . . : Yes
IPv4 Address. . . . . . . . . . . : 192.168.1.37(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 192.168.1.1
Read it as the handoff described above: DHCP Server is who gave the lease, and DNS Servers is the option 6 list that name lookups will use. To renew the lease and pick up any changes the router now hands out, run ipconfig /renew. Microsoft documents it as renewing "DHCP configuration for all adapters (if an adapter is not specified)".
To test a name lookup directly against a chosen server, use the tools in DNS lookup with nslookup and dig.
Does DHCP register the client's name in DNS?
Not on its own. RFC 2131 states that "DHCP also does not address registration of newly configured clients with the Domain Name System (DNS)". Whether a device's name shows up in DNS depends on other mechanisms, such as the client updating its own record or the DHCP server software updating DNS for it. On Windows, ipconfig /registerdns starts a manual dynamic registration of the names and addresses configured on the computer. Home routers often keep their own list of device names for local lookups, but the behavior varies by router and is not defined by DHCP itself.
Reading the symptoms: which service failed?
Because the steps run in order, the symptom tells you where to look.
| Symptom | Likely stage | First check |
|---|---|---|
| No valid IP address, or a self-assigned one | DHCP | Cable or Wi-Fi, router DHCP server enabled, then ipconfig /renew |
| Valid address, but nothing outside the local network works, even by IP | Gateway (DHCP option 3) | Default Gateway line in ipconfig /all |
| Pinging an IP address works, but names fail | DNS | DNS Servers line, then test a lookup against another resolver |
| A name opens a wrong or old address | DNS cache or record | Flush the cache with ipconfig /flushdns |
The last row uses a command Microsoft describes as flushing and resetting "the contents of the DNS client resolver cache". ipconfig /displaydns shows what that cache currently holds. For the full list of fixes when the second-to-last case happens, see DNS server not responding: how to fix it.
Why the DNS server comes from DHCP at all
The client has to learn a DNS server address from somewhere before it can use DNS, and it can't use DNS to find that address. DHCP solves this by delivering the DNS server's IP address alongside the client's own address. It also keeps management central: change the DNS servers in one place, the DHCP server, and every client picks up the change at its next renewal instead of someone editing each device. The trade-off is trust. The client believes whatever DNS server the DHCP reply names, so a rogue DHCP server on a network can steer name lookups. Switches can restrict which ports are allowed to answer DHCP requests, as covered in DHCP snooping explained.
Frequently asked questions
- Can a computer connect to the network without DHCP?
- Yes. If you type the IP address, subnet mask, default gateway and DNS server into the device yourself (a static configuration), it never needs to ask a DHCP server. DHCP only automates that setup. The network works the same way afterwards, and the device still uses DNS to look up names.
- Can I use the internet without DNS?
- You can reach a server by its IP address without DNS, because DNS only translates names into addresses. In practice almost every website, app and service is addressed by name, so without a working DNS server most things appear broken even though the connection itself is fine.
- Does the DHCP server have to be the DNS server?
- No. DHCP only tells the client which DNS servers to use (option 6). Those can be the router, which usually forwards queries onward, a server inside the company, or a public resolver. On home networks one router often plays all roles, which is why the same address shows up for gateway, DHCP server and DNS server.
- Why can I ping an IP address but not a website name?
- The network path works, so DHCP did its job and your address and gateway are fine. The name lookup is what fails, so the problem is the DNS server the client was given or the lookup itself. Check the DNS server shown by ipconfig /all, then test a lookup against a different resolver.