Free Ebook cover CCNA-Level Networking for Cloud and Web Hosting: The Essentials You Actually Use

CCNA-Level Networking for Cloud and Web Hosting: The Essentials You Actually Use

New course

13 pages

DHCP in Server and Cloud Deployments: Getting the Right Address and Gateway

Capítulo 6

Estimated reading time: 9 minutes

+ Exercise

What DHCP Does in Hosting Environments

DHCP (Dynamic Host Configuration Protocol) is how most servers and cloud instances automatically obtain an IP address and the network settings required to actually use that address. In hosting operations, DHCP is not just “getting an IP”; it is often the mechanism that delivers the default gateway, DNS servers, and search domains that determine whether the server can reach the internet, internal services, and resolve names correctly.

DHCP is typically used in: cloud VM networks, bare-metal provisioning networks, management networks (iDRAC/iLO/IPMI), container host networks, and lab/staging segments where rapid provisioning matters.

DHCP Message Flow (DORA) You’ll Troubleshoot

DHCP uses a simple four-step exchange commonly called DORA. Understanding what each step means helps you pinpoint where the process is failing.

  • Discover: The client boots and broadcasts a request to find DHCP servers.
  • Offer: A DHCP server replies with an offered IP address and options (gateway, DNS, etc.).
  • Request: The client requests the offered address (and implicitly the options) from that server.
  • Ack: The server confirms the lease and options; the client configures the interface.

Operationally: if you see Discover but no Offer, the problem is usually “no DHCP server reachable” (wrong VLAN/segment, missing relay, security policy). If you see Offer but no Ack, it can be a conflict, policy denial, or the client requesting a different address than the server will grant.

DHCP Relay (When the Server Isn’t on the Same Subnet)

In many data centers and some cloud designs, the DHCP server is not in the same L2 segment as the client. A DHCP relay (often on a router or L3 gateway) forwards the client’s broadcast to the DHCP server as a unicast and inserts relay information so the server knows which scope to use. If relay is missing or misconfigured, clients in that subnet will never receive an Offer.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

Leases: What They Are and Why They Matter

A DHCP lease is a time-bound assignment of an IP address to a client. The lease includes the address plus options (gateway, DNS, domain search, NTP, etc.).

  • Lease time: How long the client can use the address before it must renew.
  • Renewal (T1): Typically around 50% of the lease time; the client tries to renew with the original server.
  • Rebinding (T2): Typically around 87.5% of the lease time; the client tries any DHCP server if the original is unavailable.

In hosting, lease time affects stability and troubleshooting. Very short leases can cause frequent renewals and log noise; very long leases can keep a bad configuration (wrong DNS, wrong gateway) around longer than you want.

DHCP Options That Commonly Break Web Hosting

Default Gateway (Router Option)

The default gateway is the next-hop IP used for traffic outside the local subnet. If this option is missing or wrong, the server may reach only local addresses but fail to reach upstream networks (including the internet, load balancers, or monitoring systems).

DNS Servers

DNS server IPs determine where the host sends name resolution queries. A wrong DNS option can cause symptoms that look like “network down” even when IP connectivity is fine (for example, ping 8.8.8.8 works but ping example.com fails).

In hosting, a common failure is receiving an internal-only resolver (reachable only from a different network) or a resolver that blocks external domains. Another common issue is getting a resolver intended for a private management segment rather than the production segment.

Domain Search (Search Suffix)

The domain search list affects how short names are expanded. For example, if search includes corp.internal, then resolving db01 may try db01.corp.internal. Misconfigured search domains can cause the host to resolve to unintended internal names, or cause delays due to multiple failed search attempts.

Real Case 1: Instance Boots With No Connectivity Because DHCP Is Missing

Scenario: A new VM boots, the interface shows “up,” but it has no IP address and cannot reach anything. This often happens when the VM is attached to the wrong network, the DHCP service is not present on that segment, or a security policy blocks DHCP.

Step-by-step diagnosis

  • Confirm link and interface state: Ensure the NIC is up and connected to the expected virtual network/port group.
  • Inspect IP configuration: Check whether the interface has an IPv4 address and mask. If you see no address or a self-assigned address (platform-dependent), DHCP likely failed.
  • Check for a default gateway: Even if an IP exists, missing gateway means no upstream reachability.
  • Inspect lease details: Verify whether a lease exists, when it was obtained, and which DHCP server provided it.
  • Attempt a renew: Force a DHCP renew and watch for errors/timeouts.
  • Validate reachability to the gateway: Once an address is present, test reachability to the default gateway IP.

What to fix

  • Attach the instance to the correct network that has DHCP.
  • Ensure DHCP relay is configured if DHCP server is off-subnet.
  • Check security controls (port security, DHCP snooping equivalents, firewall rules) that might block DHCP traffic.

Practical commands (common OS examples)

# Linux (systemd-based): check address, routes, and DNS sources ip addr show ip route show resolvectl status  # or: cat /etc/resolv.conf  # Renew lease (varies by distro/network manager) sudo dhclient -v -r && sudo dhclient -v  # or with NetworkManager: nmcli dev show nmcli dev disconnect eth0; nmcli dev connect eth0  # Windows: check and renew ipconfig /all ipconfig /release ipconfig /renew

Real Case 2: Server Receives an Address From the Wrong Scope

Scenario: A server gets an IP address that “looks valid” but is from the wrong subnet for that rack/VLAN/tenant. It may have the wrong gateway and DNS, causing partial or complete outage. This can happen due to: miswired switchport/VLAN assignment, wrong virtual port group, incorrect DHCP relay mapping, or a rogue DHCP server.

Symptoms you’ll see

  • IP address does not match the expected subnet for that environment.
  • Default gateway is not the gateway used in that segment.
  • Server can reach some internal hosts (in the wrong subnet) but not the intended services.
  • Duplicate IP conflicts if the address overlaps with another environment.

Step-by-step diagnosis

  • Confirm the expected network: Identify the correct subnet, gateway, and DNS for this server role (production web, management, backup, etc.).
  • Inspect current IP/mask/gateway: Compare to the expected values.
  • Check which DHCP server answered: Lease details often show the DHCP server identifier; if it’s unexpected, suspect wrong relay or rogue DHCP.
  • Validate gateway reachability: If the gateway is reachable but not the right one, you’re likely on the wrong segment.
  • Renew and observe: If renew consistently returns the same wrong scope, the network attachment/relay is wrong, not a one-off.

What to fix

  • Correct VLAN/port group assignment for the server’s NIC.
  • Fix DHCP relay configuration so the relay interface maps to the correct scope.
  • Remove/contain rogue DHCP sources (common in lab environments or misconfigured appliances).
# Linux: show DHCP-provided routes and server (varies by client) ip route show journalctl -u systemd-networkd --no-pager | tail -n 200  # If using dhclient, lease info is often in: sudo cat /var/lib/dhcp/dhclient*.leases  # Windows: DHCP server and lease details ipconfig /all

Real Case 3: DNS Option Points to an Internal Resolver (Name Resolution Breaks Hosting)

Scenario: The server has a correct IP and can ping the gateway, but web apps fail because they cannot resolve external APIs, package repositories, OCSP endpoints, or upstream services. DHCP delivered DNS servers that are only reachable from a private network, or that intentionally block external resolution.

Step-by-step diagnosis

  • Confirm basic IP connectivity: Ping the default gateway IP.
  • Test reachability to the DNS server IPs: If DNS servers are unreachable, name resolution will fail even though the network is up.
  • Test name resolution explicitly: Query a known domain and observe which resolver is used.
  • Check domain search list: Ensure short names aren’t being expanded into the wrong internal namespace.
# Linux: test DNS and see which server answers resolvectl query example.com  # or: dig example.com  # show current resolver configuration resolvectl status  # Windows: test DNS resolution and show DNS servers nslookup example.com ipconfig /all

What to fix

  • Correct DHCP option for DNS servers for that scope (use the intended resolvers for that environment).
  • If split-horizon DNS is required, ensure the server is in the correct network and has access to the internal resolvers.
  • Adjust domain search list to match the operational model (avoid overly broad search lists that cause misresolution).

Verification Sequence You Can Reuse in Incidents

Use this sequence when a server “has no network” or “can’t reach the internet” after boot or after a move.

1) Confirm link and interface is up

  • Verify the NIC is enabled and connected to the correct network.
  • Check interface state (up/down) and errors.

2) Inspect IP address, mask, and default gateway

  • Confirm the IP is in the expected subnet.
  • Confirm the mask matches the scope design.
  • Confirm a default route exists and points to the expected gateway.

3) Confirm lease details

  • Identify the DHCP server that issued the lease.
  • Check lease start/end times and whether renewal is failing.
  • Confirm the options delivered (gateway, DNS, search domains).

4) Renew the lease

  • Release/renew to force a fresh DORA exchange.
  • If renew fails, focus on DHCP reachability (relay, VLAN, security policy).

5) Validate reachability to the gateway

  • Ping the default gateway IP.
  • If gateway is unreachable, suspect wrong VLAN, wrong IP/mask, or upstream L2/L3 issue.
  • If gateway is reachable but external access fails, focus on routing beyond the gateway and DNS options.
# Quick checks (Linux) ip -br addr ip route show ping -c 3 <default-gateway-ip>  # Quick checks (Windows) ipconfig ping <default-gateway-ip> route print

Static Addressing vs DHCP Reservations in Hosting Operations

Static addressing (manually configured on the server)

  • Pros: Predictable; no dependency on DHCP availability at boot; useful for certain infrastructure nodes where you want configuration fully local.
  • Cons: Higher risk of human error (wrong mask/gateway/DNS); harder to audit at scale; IP conflicts more likely during rebuilds; slower provisioning.

DHCP reservations (static mapping managed by DHCP)

  • Pros: Predictable IPs while keeping centralized control; easy rebuilds (same MAC/identifier gets same IP); consistent delivery of gateway/DNS/search options; better audit trail in DHCP logs.
  • Cons: Still depends on DHCP service/relay at boot; requires correct client identifier/MAC handling (virtual NIC changes can break the reservation); reservations must be maintained as inventory changes.

Common operational pattern in hosting: use DHCP (often with reservations) for fleets and rebuildable nodes, and reserve true static configuration for a small set of tightly controlled infrastructure endpoints where DHCP dependency is undesirable.

Now answer the exercise about the content:

A server can ping its default gateway IP, but name-based access (e.g., reaching external services by hostname) fails. Which DHCP-delivered setting is the most likely cause?

You are right! Congratulations, now go to the next page

You missed! Try again.

If IP connectivity works to the gateway but hostnames fail, the issue is often the DNS servers provided by DHCP (wrong/unreachable resolvers or ones that block external resolution).

Next chapter

DNS for Web Hosting: From Domain Name to Server IP

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.