Skip to main content

How to Configure Static IP Addresses on Linux Distributions

·475 words·3 mins
Linux Networking IP Configuration
Table of Contents

Configuring a static IP address is a common task in Linux system administration, especially for servers and networked services that require consistent connectivity. Because Linux distributions use different networking frameworks, the configuration process varies between platforms.

This guide outlines practical methods for configuring static IP addresses across several widely used Linux distributions.

🐧 Debian and Ubuntu-Based Distributions
#

Modern Debian-based systems, including Ubuntu, typically use Netplan for network configuration. Netplan relies on YAML configuration files that define network interfaces and addressing behavior.

Back Up the Existing Configuration
#

Before making changes, create a backup of the current Netplan configuration file:

sudo cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.backup

Edit the Netplan Configuration
#

Open the configuration file with a text editor:

sudo nano /etc/netplan/01-netcfg.yaml

Update the file with a static IP configuration similar to the following:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

Apply and Verify the Configuration
#

Apply the changes and verify that the IP address has been assigned:

sudo netplan apply
ip addr show eth0

πŸŸ₯ CentOS and RHEL-Based Distributions
#

CentOS and Red Hat Enterprise Linux traditionally rely on NetworkManager, with interface configuration files located in the /etc/sysconfig/network-scripts/ directory.

Identify the Network Interface
#

List available network devices to confirm the interface name:

nmcli device status

Back Up the Interface Configuration
#

Create a backup of the existing configuration file:

sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.backup

Edit the Configuration File
#

Open the interface configuration file:

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

Update it with static IP settings:

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8

Restart Networking and Verify
#

Restart the network service and confirm the IP assignment:

sudo systemctl restart network
ip addr show eth0

🟦 Fedora
#

Fedora also uses NetworkManager, but static IP configuration is commonly performed using command-line or text-based tools.

Administrators can configure networking using the interactive interface:

nmtui

Alternatively, advanced users may prefer nmcli for scripting and automation. Both tools provide reliable methods for assigning static IP addresses without directly editing configuration files.


🟒 openSUSE
#

openSUSE offers multiple tools for network configuration, including graphical and command-line options.

Using YaST
#

YaST provides a comprehensive system management interface:

  • Run sudo yast network
  • Select the desired network interface
  • Configure the static IP address and related settings

Using netconfig
#

For command-line configuration, install and use the netconfig utility:

sudo zypper install netconfig
sudo netconfig

Follow the prompts to complete the network setup.


⚠️ Important Considerations
#

  • Always back up configuration files before applying changes to avoid accidental network loss.
  • Avoid IP conflicts by ensuring the chosen address is not already in use on the network.
  • GUI tools are available on most distributions for users who prefer graphical configuration methods.

Understanding the networking tools used by each Linux distribution helps ensure reliable IP configuration and reduces downtime when managing servers or workstations.

Related

Understanding Network Port Mapping and Port Forwarding
·623 words·3 mins
Infrastructure Connectivity Cybersecurity Networking
Private vs Public IP Address Ranges Explained
·537 words·3 mins
IP Address Infrastructure Internet Protocols Networking
Linux Kernel Management: Concepts and sysctl Configuration
·542 words·3 mins
Linux Kernel