IP address configuration is one of the most critical, if simple, settings on your network devices. Workstations, servers, routers, and other components must have properly assigned IP address settings to participate on the network.
This two-part article series covers static and dynamic IP address settings and the configuration of a DHCP server. This article (part one) defines network identities, contrasts static and dynamic configurations, and covers the commands needed to manage the settings. Part two covers the deployment of a DHCP server, DHCP scope configuration, and client-side management of dynamic IP addresses.
[ You might also enjoy: The name game: Naming network interfaces in Linux ]
Network nodes have three identities: Hostname, logical address, and physical address. These three addresses provide different types of connectivity and are used in various ways during network communication.
The three identities are:
- Hostname - descriptive, easy to remember names for the benefit of humans
- IP address - logical address to uniquely identify a network node, primarily used by routers
- MAC address - physical address encoded on the network interface card (NIC), used mainly by switches
Hostnames are configured when the OS is installed, and MAC addresses are hard-coded on NICs. Sysadmins typically configure IP address information on servers, workstations, portable systems, and network devices.
I’ll cover the two primary ways that IP address information is provided to the nodes: Static and dynamic configurations.
Static and dynamic configurations:
- Static - manually configured by sysadmins
- Dynamic - automatically leased by clients from a Dynamic Host Configuration Protocol (DHCP) server
The standard settings are IP addresses, subnet masks, default gateways, and nameservers.
NetworkManager primarily handles network configuration. NetworkManager can be used in a GUI, TUI, or CLI environment.
nmcli process to set a static IP configuration is to create a connection profile and then set the values desired. Red Hat has documentation here.
Here is an example of creating a network connection named home-network with an IP address of 192.168.2.200/24, a default gateway of 192.168.2.1, and a name server of 184.108.40.206:
# nmcli connection add con-name home-network ifname enp7s0 type ethernet # nmcli connection modify home-network ipv4.gateway 192.168.2.1 # nmcli connection modify home-network ipv4.addresses 192.168.2.200/24 # nmcli connection modify home-network ipv4.dns 220.127.116.11 # nmcli connection up home-network
The GUI configuration can be accomplished by selecting the Manual button and then filling in the blanks with the appropriate information.
Recall that you can make no typographical errors when configuring IP addresses, and duplicate addresses will cause network connection problems.
Why static configurations?
Static IP addresses do not change unless the administrator actively reconfigures them. This is an important fact when it comes to servers because most client computers need to be able to find servers consistently.
For example, an NFS file server hosting department directories needs to keep the same IP address over time as configuration files such as a client computer’s
/etc/fstab file may use the IP address for connectivity.
Other network nodes also may need an unchanging network identity. Appliance devices such as firewalls or proxies, print servers, name resolution servers, web servers, and virtually all other infrastructure devices need a consistent identity. Sysadmins will almost always configure these systems with static IP address information.
It is essential to track your statically assigned IP addresses. Depending on the size of your environment, this might be so simple as a text document or a spreadsheet, all the way up to specialized software that integrates with directory services and DHCP. I find it’s best to at least track IP address (and subnet mask), MAC address (not essential), hostname, role on the network (justifies why the devices have a static IP), and any additional notes.
The devices that require a static IP configuration are a relatively small percentage of your network. Most network devices are end-user systems such as workstations, laptops, phones, tablets, and other transient devices. In addition, these systems do not usually host network services that need to be discoverable by other computers.
IP address configurations are unforgiving when it comes to duplicates and typos. In addition, static IP address settings are fairly time-consuming. Finally, IP address settings tend to be temporary, especially with the advent of portable devices like laptops, phones, and tablets. To save time and reduce the chances of a mistake, dynamic IP address allocation is preferable for these kinds of nodes.
Linux systems are configured as DHCP clients by using NetworkManager.
Here is an example of adding a network connection profile configured to lease an IP address from DHCP:
# nmcli connection add con-name home-network ifname enp7s0 type ethernet
By not specifying an address NetworkManager assumes the DHCP client role.
Here is a screenshot of a dynamic IP address configuration from the GUI:
The dhclient command
dhclient command is also used to manage dynamic IP address configurations. However, in RHEL 8, network configurations, including DHCP, are handled by NetworkManager. Older RHEL versions rely on
dhclient, as do some other distributions.
ip route command displays lease information.
The second article in this series goes over the
dhclient command in more detail.
[ Free cheat sheet: Get a list of Linux utilities and commands for managing servers and networks. ]
IP address settings are crucial to network communications. Values such as the IP address, subnet mask, default gateway, and nameservers can be manually managed, but sysadmins must be very careful not to make any mistakes. Static settings don’t change unless the administrator reconfigures them, so they are essential for servers whose services are made available across the network.
Dynamic IP configurations are far more convenient for systems that don’t host network services, such as end-user devices. Furthermore, many of these devices enter and leave the network regularly, and it would be very time-consuming to set IP values each time manually. Instead, a DHCP server is used to host a pool of available addresses that client systems can lease.
Understanding the difference between static and dynamic IP addresses is straightforward but essential for administrators. As a general rule, servers and network devices utilize static, unchanging IPs, while client devices rely on dynamically allocated IP configurations.