<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Dhcp · Network Doodles</title><link>https://networkdoodles.com/tags/dhcp/</link><description>Network automation, from first playbook to agentic operations. Ansible, NetBox, MCP, Python and the occasional doodle.</description><language>en-us</language><managingEditor>David Henderson</managingEditor><lastBuildDate>Mon, 16 Nov 2026 09:00:00 -0500</lastBuildDate><atom:link href="https://networkdoodles.com/tags/dhcp/index.xml" rel="self" type="application/rss+xml"/><item><title>DHCP on the Wire: How a Host Gets an Address (Wireshark 101, Lesson 4)</title><link>https://networkdoodles.com/lessons/wireshark-101/dhcp/</link><pubDate>Mon, 16 Nov 2026 09:00:00 -0500</pubDate><dc:creator>David Henderson</dc:creator><guid>https://networkdoodles.com/lessons/wireshark-101/dhcp/</guid><category>wireshark</category><category>packet-capture</category><category>networking-basics</category><category>dhcp</category><description>DHCP's four messages in a capture, the options that matter, leases and renewal, and how a relay turns a broadcast into unicast with giaddr in it.</description><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>DHCP, the Dynamic Host Configuration Protocol, gives a host its address and everything else it needs to use
the network, in four messages: <strong>Discover</strong>, <strong>Offer</strong>, <strong>Request</strong>, <strong>ACK</strong>. The first is sent before the
host has any address, from <code>0.0.0.0</code> to <code>255.255.255.255</code>. The address is only ever <strong>leased</strong>, so the host
renews it, directly with the server, before the lease runs out. And because routers don&rsquo;t pass broadcasts on,
a router acting as a <strong>DHCP relay</strong> carries those messages to a server on another network, writing its own
address into them so the server knows which network the client is on.</p>
<p>Networking 101&rsquo;s <a href="/lessons/networking-101/task-4-1/">DHCP lesson</a> walked through DORA as an animation. This
lesson is the same story in real packets from the lab, where the DHCP server is two hops away from the laptop
and r1 relays every message.</p>
<hr>
<h2 id="how-does-a-host-send-anything-without-an-address">How does a host send anything without an address?</h2>
<p>It cheats, politely. A host that has no IP address still has a MAC address, and it can still send an IP
packet: it just has to make up the addresses. The <strong>Discover</strong> goes:</p>
<ul>
<li><strong>from</strong> <code>0.0.0.0</code>, which means <em>this host, no address yet</em>;</li>
<li><strong>to</strong> <code>255.255.255.255</code>, the <strong>limited broadcast</strong>: everyone on this network;</li>
<li>in an Ethernet frame to <code>ff:ff:ff:ff:ff:ff</code>, the broadcast MAC address;</li>
<li>over UDP, from port <strong>68</strong> (the client&rsquo;s port) to port <strong>67</strong> (the server&rsquo;s).</li>
</ul>
<p>Here are the DHCP frames of the lab&rsquo;s capture, taken on the laptop&rsquo;s cable:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">    6 0.613249583 192.168.1.175 → 192.168.2.53 DHCP 342 DHCP Release  - Transaction ID 0x54c3a747
</span></span><span class="line"><span class="cl">    7 2.240006876      0.0.0.0 → 255.255.255.255 DHCP 342 DHCP Discover - Transaction ID 0xd9e69210
</span></span><span class="line"><span class="cl">    8 2.246596042  192.168.1.1 → 192.168.1.175 DHCP 342 DHCP Offer    - Transaction ID 0xd9e69210
</span></span><span class="line"><span class="cl">    9 2.273590042      0.0.0.0 → 255.255.255.255 DHCP 342 DHCP Request  - Transaction ID 0xd9e69210
</span></span><span class="line"><span class="cl">   10 2.281617209  192.168.1.1 → 192.168.1.175 DHCP 347 DHCP ACK      - Transaction ID 0xd9e69210
</span></span></code></pre></div><p>The lab makes the laptop give its address back first (the Release in frame 6, more on that below), then ask
for a new one. Frames 7 to 10 are DORA. From Discover to ACK took 41.6 milliseconds.</p>
<p>The four messages share one <strong>transaction ID</strong>, <code>0xd9e69210</code>: a random number the client picks for each
exchange. Every answer carries it back. On a network where twenty laptops boot at once, it&rsquo;s how each one
picks its own answers out of the broadcast noise, and in Wireshark it&rsquo;s how you pick one client&rsquo;s exchange out
of a busy capture: filter <code>dhcp.id == 0xd9e69210</code>.</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th>Message</th>
          <th>IP from → to</th>
          <th>What it says</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>D</strong></td>
          <td>Discover</td>
          <td><code>0.0.0.0</code> → <code>255.255.255.255</code></td>
          <td><em>I need an address. Any servers out there?</em></td>
      </tr>
      <tr>
          <td><strong>O</strong></td>
          <td>Offer</td>
          <td>server (here, the relay) → offered address</td>
          <td><em>You can have 192.168.1.175, with these settings</em></td>
      </tr>
      <tr>
          <td><strong>R</strong></td>
          <td>Request</td>
          <td><code>0.0.0.0</code> → <code>255.255.255.255</code></td>
          <td><em>I&rsquo;ll take 192.168.1.175, from server 192.168.2.53</em></td>
      </tr>
      <tr>
          <td><strong>A</strong></td>
          <td>ACK</td>
          <td>server (the relay) → the address</td>
          <td><em>It&rsquo;s yours, for 600 seconds</em></td>
      </tr>
  </tbody>
</table>
<p>Why is the Request still a broadcast, when the laptop already knows the server? Because more than one server
may have made an offer. The Request names the one the laptop chose (option 54, the server identifier) and
the address it&rsquo;s taking (option 50), and broadcasting it tells <em>every</em> server at once: the chosen one
confirms, and the others can put their offered addresses back.</p>
<p>The Offer and ACK go to the offered address directly, not to everyone. The laptop&rsquo;s Discover had its
<strong>broadcast flag</strong> set to 0, which tells the server the client can receive a unicast before its address is
configured. A client that can&rsquo;t would set it to 1, and the answers would be broadcast.</p>
<hr>
<h2 id="which-dhcp-options-matter">Which DHCP options matter?</h2>
<p>The address itself is in a fixed field near the top of the message, <strong>Your (client) IP address</strong>. Everything
else is an <strong>option</strong>: a numbered setting with a length and a value. The numbers come from
<a href="https://www.rfc-editor.org/rfc/rfc2132">RFC 2132</a>, and they&rsquo;re worth learning, because Wireshark shows them
by number. Here&rsquo;s the lab&rsquo;s Offer:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">Dynamic Host Configuration Protocol (Offer)
</span></span><span class="line"><span class="cl">    Message type: Boot Reply (2)
</span></span><span class="line"><span class="cl">    Hops: 1
</span></span><span class="line"><span class="cl">    Transaction ID: 0xd9e69210
</span></span><span class="line"><span class="cl">    Your (client) IP address: 192.168.1.175
</span></span><span class="line"><span class="cl">    Relay agent IP address: 192.168.1.1
</span></span><span class="line"><span class="cl">    Client MAC address: aa:aa:aa:11:11:11 (aa:aa:aa:11:11:11)
</span></span><span class="line"><span class="cl">    Option: (53) DHCP Message Type (Offer)
</span></span><span class="line"><span class="cl">    Option: (54) DHCP Server Identifier (192.168.2.53)
</span></span><span class="line"><span class="cl">    Option: (51) IP Address Lease Time
</span></span><span class="line"><span class="cl">        IP Address Lease Time: 10 minutes (600)
</span></span><span class="line"><span class="cl">    Option: (58) Renewal Time Value
</span></span><span class="line"><span class="cl">        Renewal Time Value: 5 minutes (300)
</span></span><span class="line"><span class="cl">    Option: (59) Rebinding Time Value
</span></span><span class="line"><span class="cl">        Rebinding Time Value: 8 minutes, 45 seconds (525)
</span></span><span class="line"><span class="cl">    Option: (1) Subnet Mask (255.255.255.0)
</span></span><span class="line"><span class="cl">    Option: (15) Domain Name
</span></span><span class="line"><span class="cl">        Domain Name: lab
</span></span><span class="line"><span class="cl">    Option: (6) Domain Name Server
</span></span><span class="line"><span class="cl">        Domain Name Server: 192.168.2.53
</span></span><span class="line"><span class="cl">    Option: (3) Router
</span></span><span class="line"><span class="cl">        Router: 192.168.1.1
</span></span></code></pre></div><p>(Some lines left out.) The ones to know:</p>
<table>
  <thead>
      <tr>
          <th>Option</th>
          <th>Name</th>
          <th>Lab value</th>
          <th>Why it matters</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>53</strong></td>
          <td>DHCP Message Type</td>
          <td>Offer</td>
          <td>which of the messages this is: Wireshark&rsquo;s summary comes from it</td>
      </tr>
      <tr>
          <td><strong>54</strong></td>
          <td>Server Identifier</td>
          <td><code>192.168.2.53</code></td>
          <td>the real server, whoever delivered the message</td>
      </tr>
      <tr>
          <td><strong>51</strong></td>
          <td>Lease Time</td>
          <td>600 s</td>
          <td>how long the address is lent for</td>
      </tr>
      <tr>
          <td><strong>58</strong></td>
          <td>Renewal Time (T1)</td>
          <td>300 s</td>
          <td>when to start renewing</td>
      </tr>
      <tr>
          <td><strong>59</strong></td>
          <td>Rebinding Time (T2)</td>
          <td>525 s</td>
          <td>when to ask any server, if the first won&rsquo;t answer</td>
      </tr>
      <tr>
          <td><strong>1</strong></td>
          <td>Subnet Mask</td>
          <td><code>255.255.255.0</code></td>
          <td>which addresses are neighbors (ARP) and which go to the gateway</td>
      </tr>
      <tr>
          <td><strong>3</strong></td>
          <td>Router</td>
          <td><code>192.168.1.1</code></td>
          <td>the default gateway</td>
      </tr>
      <tr>
          <td><strong>6</strong></td>
          <td>DNS Server</td>
          <td><code>192.168.2.53</code></td>
          <td>where to send name lookups</td>
      </tr>
      <tr>
          <td><strong>15</strong></td>
          <td>Domain Name</td>
          <td><code>lab</code></td>
          <td>added to short names, so <code>web</code> becomes <code>web.lab</code></td>
      </tr>
  </tbody>
</table>
<p>The client has its own say, too. Its Discover carries option <strong>55</strong>, the Parameter Request List: the
options it wants. The lab&rsquo;s laptop asks for 1, 3, 6, 12, 15, 28 and 42. A server only has to send what it has,
and a missing option is a common reason a host &ldquo;has an address but can&rsquo;t reach anything&rdquo;: no option 3, no
gateway.</p>
<p>Every setting the laptop has, apart from its MAC address, came from those few hundred bytes. When a host&rsquo;s
network settings look wrong, the Offer and the ACK are the first place to look, because they&rsquo;re the only
record of what it was told.</p>
<hr>
<h2 id="how-do-leases-and-renewal-work">How do leases and renewal work?</h2>
<p>An address is lent, not given. <a href="https://www.rfc-editor.org/rfc/rfc2131">RFC 2131</a>, the DHCP standard, gives
the client two timers, and the lab&rsquo;s numbers show its defaults exactly:</p>
<table>
  <thead>
      <tr>
          <th>Time</th>
          <th>Lab value</th>
          <th>Share of the lease</th>
          <th>What the client does</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><strong>T1</strong>, renewal</td>
          <td>300 s</td>
          <td>50%</td>
          <td>sends a Request <strong>unicast</strong> to the server that gave the lease</td>
      </tr>
      <tr>
          <td><strong>T2</strong>, rebinding</td>
          <td>525 s</td>
          <td>87.5%</td>
          <td>no answer yet: broadcasts a Request to any server</td>
      </tr>
      <tr>
          <td>lease end</td>
          <td>600 s</td>
          <td>100%</td>
          <td>still no answer: stops using the address</td>
      </tr>
  </tbody>
</table>
<p>The renewal is the interesting one on the wire. By T1 the client has an address and knows the server&rsquo;s
(option 54), so it sends an ordinary unicast packet, from its own address to the server&rsquo;s, routed like any
other traffic. No broadcast, no relay. If you capture a renewal, it looks nothing like DORA: one Request and one
ACK, with real addresses on both.</p>
<p>Ten minutes is a short lease. It suits a lab where you want to watch a renewal, and networks where devices
come and go quickly. Longer leases mean fewer renewals and a pool that empties more slowly when devices leave
without saying goodbye.</p>
<h3 id="release">Release</h3>
<p>A client that&rsquo;s leaving can hand the address back with a <strong>Release</strong>, and the lab&rsquo;s capture starts with one.
Frame 6 goes from the laptop&rsquo;s address, <code>192.168.1.175</code>, to the server&rsquo;s, <code>192.168.2.53</code>: unicast, like a
renewal. Just before it, the laptop sent an ARP request for <code>192.168.1.1</code>. The server is on another network,
so the Release went to the gateway&rsquo;s MAC address like any other routed packet (that&rsquo;s
<a href="/lessons/wireshark-101/arp/">lesson 3</a>&rsquo;s rule at work). A Release is optional (RFC 2131 says a client <em>may</em>
send one), and a device that&rsquo;s simply unplugged can&rsquo;t send one at all. That&rsquo;s why the lease time, not the
Release, is what really frees addresses.</p>
<hr>
<h2 id="why-do-dhcp-broadcasts-need-a-relay">Why do DHCP broadcasts need a relay?</h2>
<p>Because the Discover is a broadcast, and <strong>routers don&rsquo;t forward broadcasts</strong>. That&rsquo;s the point of a router,
and it&rsquo;s what keeps a broadcast domain to one network (Networking 101&rsquo;s
<a href="/lessons/networking-101/task-2-2/">lesson on domains</a>). Without help, every network would need its own DHCP
server.</p>
<p>Real networks don&rsquo;t work like that. A company with dozens of offices runs a handful of DHCP servers in its data
centers. What connects them is the <strong>DHCP relay</strong>: the router on the client&rsquo;s network listens for DHCP
broadcasts and passes each one on to a server, as a unicast packet that can be routed anywhere.</p>
<p>On Cisco-style routers, CapeOS included, one line on the client-facing interface turns it on. Here&rsquo;s r1&rsquo;s:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">interface GigabitEthernet1
</span></span><span class="line"><span class="cl"> description home network (sw1)
</span></span><span class="line"><span class="cl"> ip address 192.168.1.1 255.255.255.0
</span></span><span class="line"><span class="cl"> ip helper-address 192.168.2.53
</span></span></code></pre></div><p><code>ip helper-address 192.168.2.53</code> means: <em>DHCP broadcasts that arrive here, send to 192.168.2.53</em>.</p>
<hr>
<h2 id="what-does-a-relayed-discover-look-like">What does a relayed Discover look like?</h2>
<p>The lab captures both sides of r1 at once: its home side (sw1&rsquo;s port towards r1) and its side towards r2. Here
are the first DHCP frames, as frame, interface, IP source and destination, UDP ports, hops, the relay address
and the summary:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">7	sw1:eth1	0.0.0.0	255.255.255.255	68	67	0	0.0.0.0	DHCP Discover - Transaction ID 0x5fc77b2d
</span></span><span class="line"><span class="cl">8	r1:eth2	192.168.1.1	192.168.2.53	67	67	1	192.168.1.1	DHCP Discover - Transaction ID 0x5fc77b2d
</span></span><span class="line"><span class="cl">9	r1:eth2	192.168.2.53	192.168.1.1	67	67	1	192.168.1.1	DHCP Offer    - Transaction ID 0x5fc77b2d
</span></span><span class="line"><span class="cl">10	sw1:eth1	192.168.1.1	192.168.1.175	67	68	1	192.168.1.1	DHCP Offer    - Transaction ID 0x5fc77b2d
</span></span></code></pre></div><p>It&rsquo;s a different exchange from the one above, so a different transaction ID, but one ID throughout: one
conversation, carried in two hops. Follow the Discover through r1:</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th>On the home network (<code>sw1:eth1</code>)</th>
          <th>After r1 (<code>r1:eth2</code>)</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>IP source</td>
          <td><code>0.0.0.0</code></td>
          <td><code>192.168.1.1</code>, r1</td>
      </tr>
      <tr>
          <td>IP destination</td>
          <td><code>255.255.255.255</code></td>
          <td><code>192.168.2.53</code>, the server</td>
      </tr>
      <tr>
          <td>UDP ports</td>
          <td>68 → 67</td>
          <td>67 → 67</td>
      </tr>
      <tr>
          <td>Hops</td>
          <td>0</td>
          <td>1</td>
      </tr>
      <tr>
          <td>Relay agent IP address (giaddr)</td>
          <td><code>0.0.0.0</code></td>
          <td><code>192.168.1.1</code></td>
      </tr>
  </tbody>
</table>
<p>r1 didn&rsquo;t forward the broadcast. It received it, and sent a <strong>new</strong> packet with the same DHCP message inside,
changed in two places. It added one to <strong>hops</strong>, a counter that stops messages being relayed in circles. And
it wrote its own address on the receiving interface into the <strong>Relay agent IP address</strong> field, which RFC 2131
calls <strong>giaddr</strong> (<em>gateway IP address</em>).</p>
<h3 id="how-giaddr-picks-the-pool">How giaddr picks the pool</h3>
<p>giaddr is the most important field in a relayed message. The server can&rsquo;t tell where the client is from the
packet&rsquo;s source: the client has no address, and the packet arrived from r1 anyway. giaddr tells it: <em>this
client is on the network where 192.168.1.1 lives</em>. The server finds the range that contains that address and
offers from it.</p>
<p>The lab&rsquo;s DHCP server, dnsmasq on the dns host, isn&rsquo;t on <code>192.168.1.0/24</code> at all. It has one range, for that
network, <code>192.168.1.100</code> to <code>192.168.1.199</code>, and it picks that range because giaddr is <code>192.168.1.1</code>. The
laptop got <code>192.168.1.175</code>.</p>
<h3 id="why-the-offer-comes-from-the-relay">Why the Offer comes from the relay</h3>
<p>The server sends its answer back to giaddr, to UDP port 67 on the relay (frame 9). r1 then delivers it on the
home network, from its own address, <code>192.168.1.1</code>, to the client (frame 10). So the laptop only ever talks to
r1: its Offer and ACK arrive <strong>from 192.168.1.1</strong>, while option 54 inside them names the real server,
<code>192.168.2.53</code>.</p>
<p>That&rsquo;s not a contradiction, and it&rsquo;s useful. The IP source tells you who delivered the message. Option 54
tells you who made the decision. When something&rsquo;s wrong with what a client was given, option 54 is the
server whose logs you need.</p>
<hr>
<h2 id="what-i-see-go-wrong">What I see go wrong</h2>
<p><strong>DHCP works on one network and not another.</strong> Nearly always a relay problem. Capture both sides of the
router. No relayed copy on the server side means the router isn&rsquo;t relaying: a missing <code>ip helper-address</code>, or
one on the wrong interface. A relayed copy with no answer means the server has no range for that giaddr, or
something between the relay and the server blocks UDP port 67.</p>
<p><strong>Two servers answering.</strong> A second DHCP server on the network, often a home router or a test box plugged into
the wrong port, sends Offers too. In a capture that&rsquo;s two Offers with the same transaction ID and different
option 54 values. Clients take whichever they like, and some of them end up with the wrong gateway or DNS server.
Filter <code>dhcp.option.dhcp == 2</code> and look at the server identifiers.</p>
<p><strong>A client with an address and no connectivity.</strong> Read the ACK. A missing or wrong option 3 (no gateway) or 6
(no DNS server) explains it before you touch anything else.</p>
<p><strong>Discovers with no Offer at all.</strong> The pool may be full, especially with long leases and a lot of
short-lived devices. The client keeps sending Discovers, each with a new transaction ID. Many operating
systems then give themselves a link-local address from <code>169.254.0.0/16</code>
(<a href="https://www.rfc-editor.org/rfc/rfc3927">RFC 3927</a>), which is a reliable sign that DHCP failed.</p>
<p><strong>Expecting to see renewals in a broadcast capture.</strong> Renewals are unicast to the server. A capture on another
host&rsquo;s switch port won&rsquo;t show them. A capture on the client&rsquo;s cable, or near the server, will.</p>
<hr>
<h2 id="try-it">Try it</h2>
<p><a href="/labs/wireshark-101/#chapter-4">Chapter 4 of the lab</a> has you capture the laptop releasing its address and
asking for a new one, read the lease, the gateway and the DNS server out of the Offer, and then capture both
sides of r1 at once to watch the Discover change as it&rsquo;s relayed.</p>
<h2 id="whats-next">What&rsquo;s next</h2>
<p>With an address, a gateway and a DNS server, the laptop is ready to look up a name. <a href="/lessons/wireshark-101/dns/">Lesson 5</a> is about DNS:
the question and answer behind every name you type, and the extra lookups the domain name from option 15 adds.</p>
]]></content:encoded></item></channel></rss>