Sub topic 4
Static addresses versus DHCP
This chapter assumes that you can use a Linux shell, understand IPv4 subnets and default gateways, use sudo, and recover access through a console or out-of-band connection if a network change fails.
A server needs an IPv4 address to communicate on its local network. An address such as 192.168.1.50/24 contains two parts:
192.168.1.50is the host address./24is the prefix length. It says that addresses from192.168.1.0through192.168.1.255belong to the same local subnet.
The server also usually needs a default gateway. The gateway is the router that receives traffic for destinations outside the local subnet. DNS servers translate names such as example.com into addresses.
How DHCP works
DHCP, or Dynamic Host Configuration Protocol, automatically provides network settings to a client. A DHCP server usually supplies:
- An IPv4 address
- A prefix length or subnet mask
- A default gateway
- DNS server addresses
- A lease duration
The client does not own the address permanently. It renews the lease before it expires. The address might remain the same for a long time, but the DHCP server is allowed to change it.
The basic exchange is often described as DORA:
- The client broadcasts a DHCP Discover message.
- A DHCP server sends an Offer.
- The client sends a Request for the offered settings.
- The server sends an Acknowledgement.
A DHCP client therefore needs access to the network and a reachable DHCP server during startup. If the server is on another subnet, a DHCP relay must forward these messages.
How a static address works
With a static address, the server itself has a fixed configuration. The address, prefix length, gateway, and DNS servers are stored in the operating system's network configuration.
A static address is useful when other systems must reliably reach the server. Common examples include:
- Web servers
- Database servers
- Monitoring systems
- DNS and directory servers
- Hosts referenced by firewall rules or access lists
A static address does not automatically make the server reachable. The prefix length must match the network, the gateway must be correct, and firewalls must allow the required traffic.
| Method | Where the address is chosen | Main benefit | Common risk |
|---|---|---|---|
| DHCP lease | DHCP server | Easy centralized management | Address can change |
| DHCP reservation | DHCP server, based on client identity | Fixed result with centralized control | Depends on DHCP availability |
| Static configuration | Linux host | Predictable and independent of DHCP | Duplicate or incorrect settings |
A DHCP reservation is often a good alternative to a host-side static configuration. The DHCP server always assigns the same address to a known client, usually based on its MAC address or another client identifier. However, the server still depends on DHCP during startup. Network administrators must also ensure that the reserved address is excluded from any general DHCP pool.
ip -4 address show
ip route show
resolvectl statusThese commands show the current address, routes, and resolver settings. Run them before changing a server so that you know whether it currently uses DHCP and which values you may need to preserve.
Choosing between the methods
Use DHCP when the host is temporary, easily replaced, or managed through centralized DHCP policy. DHCP reduces manual errors and makes changes easier to distribute.
Use a static configuration when the address is part of the service's identity or when the host must continue configuring itself without a DHCP server. Record the chosen address and reserve it outside the DHCP pool. Never choose an address by guessing. An address already assigned to another device can cause intermittent and difficult-to-diagnose connectivity problems.
For many production environments, a DHCP reservation gives the operational benefits of a fixed address while keeping address management in one place. For critical infrastructure, a host-side static address may be preferable when DHCP availability is not guaranteed.
The effect of an incorrect choice
A missing or expired DHCP lease can leave the interface without a usable address. A wrong prefix length can make local devices appear unreachable because the server decides that traffic should use the gateway instead of the local network, or the reverse.
A wrong gateway allows local communication but usually prevents access to other networks. A wrong DNS setting can make names fail while direct connections to IP addresses still work. These failures should be tested separately rather than treated as one general “network problem.”
Before selecting static configuration, confirm the address, prefix length, gateway, DNS servers, and ownership of the address. Keep a recovery path available, especially when the server is remote. The next configuration steps depend on whether the distribution uses Netplan, NetworkManager, or another network manager.
Exercise
A server must always use 192.168.1.50, but the organization manages all addresses centrally through DHCP. Which option should you investigate first, and what must you verify?
Show answer
Investigate a DHCP reservation first. Verify that the reservation identifies the correct client, that 192.168.1.50 is outside the general pool or excluded from it, and that the DHCP service is available when the server starts.