When you need a Linux system to have a static IP address rather than one that is set dynamically by DHCP, all that's required is some configuration changes and a restart. Follow these steps to make the switch. Credit: Uqbar is back IP addresses on Linux systems are often assigned automatically by Dynamic Host Configuration Protocol (DHCP) servers. These are referred to as “dynamic addresses” and may change any time the system is rebooted. When a system is a server or will be remotely administered, however, it is generally more convenient for these systems to have static addresses, providing stable and consistent connections with users and applications. Fortunately, the steps required to change a Linux system’s IP address from dynamic to static are fairly easy, though they will be a little different depending on the distribution you are using. In this post, we’ll look at how this task is managed on both Red Hat (RHEL) and Ubuntu systems. There’s no simple command that you can run to determine whether the IP address on a Linux system is assigned by DHCP or static. If it changes when the system restarts, it’s clearly dynamically assigned, but even a dynamic address has some resistance to change. The best way is to look at the configuration file. More on this in the sections below. RHEL 8 To configure a static IP address on a Red Hat system, let’s start by listing NetworkManager’s connection. The nmcli command shown below will list network connections and devices on the system. Note that the device names and the connection names are not the same. $ nmcli dev status DEVICE TYPE STATE CONNECTION wlo1 wifi connected Comtrend7FB9 virbr0 bridge connected virbr0 enp3s0 ethernet unavailable -- lo loopback unmanaged -- virbr0-nic tun unmanaged -- To change the network interface from dynamic to static, you need to edit the file in the /etc/sysconfig/network-scripts directory that represents the public interface. In this example, it’s called ifcfg-Comtrend7BF9 (ifcfg- followed by the name of the connection). The boot protocol “BOOTPROTO=dhcp” line needs to be changed to “BOOTPROTO=static”. In addition, the IP address to be used has to be added to the file. The end result will look something like this (NOTE: Don’t add the “arrows” inserted below to highlight the lines you need to focus on): HWADDR=7C:67:2A:CF:EF:9F ESSID=Comtrend7FB9 MODE=Managed KEY_MGMT=WPA-PSK SECURITYMODE=open MAC_ADDRESS_RANDOMIZATION=default TYPE=Wireless IPADDR=192.168.0.22 static Run the command systemctl restart NetworkManager after the changes have been made to make the changes effective. Ubuntu 18.10 The nmcli (network manager command line interface) command can be used to list the network interfaces on an Ubuntu system. In the output below, we see both a loopback and a public network interface listed. The device on your system may have a different name. This one that reflects the location of the hardware. Ubuntu> nmcli d DEVICE TYPE STATE CONNECTION enp0s25 ethernet unmanaged -- lo loopback unmanaged -- To examine the network interface configuration settings on an Ubuntu system, you would use a command like this: Ubuntu> cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto enp0s25 iface enp0s25 inet dhcp You can see from the last line in this output that the eth0 interface is currently assigned by DHCP. To change the setting to dynamic, you would change "dhcp" to "static" and add some other lines as well. For example, in the file as shown below, we have changed dhcp to static and specified the IP address we want to use along with other settings: # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto enp0s25 iface enp0s25 inet static address 192.168.0.11 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 Restart the networking service or reboot the system to make the changes effective. Wrap-up Changing network settings should be done only when the changes will not affect current connections and you can back out the changes if needed. It's always a good idea to make a copy of any configuration file before you make changes. Giving your backup copy a predictable name such as interfaces.prev, interfaces.orig or interfaces- will make it a little easier to identify. Related content news F5, Nvidia team to boost AI, cloud security F5 and Nvidia team to integrate the F5 BIG-IP Next for Kubernetes platform with Nvidia BlueField-3 DPUs. By Michael Cooney Oct 24, 2024 3 mins Generative AI Cloud Security Cloud Computing analysis AWS, Google Cloud certs command highest pay Skillsoft’s annual ranking finds AWS security certifications can bring in more than $200,000 while other cloud certifications average more than $175,000 in the U.S. By Denise Dubie Oct 24, 2024 8 mins Certifications IT Jobs Careers opinion Why enterprises should care more about net neutrality Net neutrality policies are the most significant regulatory influence on the Internet and data services, and they're the reason why end-to-end Internet QoS isn’t available. By Tom Nolle Oct 23, 2024 7 mins Network Management Software Telecommunications Industry news Network jobs watch: Hiring, skills and certification trends What IT leaders need to know about expanding responsibilities, new titles and hot skills for network professionals and I&O teams. By Denise Dubie Oct 23, 2024 33 mins Careers Data Center Networking PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe