Quick Guide to Setting a Temporary Static IP Address in Linux
08:23, 21.04.2026
Introduction
Configuring a static IP address in Linux is an essential task for system administrators and developers. Whether for debugging, setting up servers, or ensuring network stability, understanding how to manage IP configurations can make network management smoother and more predictable. This guide covers how to temporarily and permanently configure a static IP address on various Linux distributions.
Understanding Dynamic vs Static IP Addresses
Dynamic IP addresses, assigned by DHCP (Dynamic Host Configuration Protocol), change over time, while static IPs remain constant. Static IPs are crucial for servers and applications requiring consistent network identification. This guide demonstrates transitioning from dynamic to static IP settings for various Linux distributions.
Configuring a Static IP on Linux
Many people still opt for ip command to configure their static IP on Linux, even though there are many tools available. Due to its commonality, we will show you how to configure static IP using ip command.
Viewing Current Network Settings
To view current IP settings, use:
ip addr show
This provides details about interfaces and assigned IP addresses.
Evaluating the Role of DHCP
DHCP dynamically assigns IPs to devices. Disabling it for static IP configuration ensures consistent network performance, and comes down to controlling a server’s daemon (dhcpd) and a client’s daemon (dhcpcd):
$ systemctl stop dhcpcd dhcpd $ systemctl disable dhcpcd dhcpd
Whether we turn off the DHCP largely depends on the system we’re using and our needs, since we may not need to disable DHCP at all if it’s properly configured.
Setting a Temporary Static IP Using the ip Command
Use the ip command to set a temporary static IP address:
sudo ip addr add <IP address>/<CIDR> dev <interface>
Example:
sudo ip addr add 192.168.1.100/24 dev eth0
The configuration needs to be reset after a reboot.
Establishing a Permanent Static IP with the ip Command
To make the static IP permanent, you can add the configuration to network interface files specific to your Linux distribution or use ip to set a static IP. We will show it on a device called “eth0”:
$ ip address flush dev eth0
$ ip route flush dev eth0
$ ip address add 192.168.6.66/24 brd + dev eth0
$ ip route add 192.168.6.1 dev eth0
$ ip route add default via 192.168.6.1 dev eth0
$ ip address show dev eth0
[...]
inet 192.168.6.66/24 brd 192.168.6.255 scope global eth0
[...]
After clearing all addresses and routes from eth0, we assign a new static address and gateway. To ensure the configuration is correct, check the interface details to confirm that the dynamic setting is no longer present.
And again, after a reboot, the configuration has to be redone.
Managing Network Tools
Detecting Installed Network Managers
Before configuring a network on a Linux system, we should identify and disable network managers that aren’t used. Common network managers include NetworkManager, Netplan, and systemd-networkd. You can identify the active manager with:
systemctl | grep network
Controlling Network Managers Effectively
Disable conflicting services when manually configuring static IPs using the following command:
sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager
Setting a Static IP on Debian-Based Systems
The default structure of network configuration files in Debian and its derivatives is as follows:
$ tree /etc/network
/etc/network
├── if-down.d
├── if-post-down.d
├── if-pre-up.d
├── if-up.d
├── interfaces
└── interfaces.d
The tree command points to script directories in relation to the interface going up or down.
Adding Interface Configurations
Edit the /etc/network/interfaces file using:
auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.1
Restarting the Network or Specific Interfaces
Apply the changes with:
sudo systemctl restart networking
Verifying the Configuration
Confirm the static IP setup using:
ip addr show dev eth0
Here, we will see the changes being applied through ip.
Configuring a Static IP on Red Hat and RPM-Based Systems
The structure of network configuraton files in RedHat, openSUSE, SUSE, Fedora, CentOS, Oracle Linux and other RPM-based system is the following:
$ tree /etc/sysconfig -P 'network'
/etc/sysconfig
├── network
└── network-scripts
The -p flag in the tree command allows to filter and receive only network-related items in the directory.
Using network-scripts and NetworkManager
The network-scripts package has different tools that perform different functions, including:
- ifup*, ifdown* (and other /etc/sysconfig/network-scripts) directory scripts
- /etc/init.d/network script to start, stop and restart network components
- ifup and ifdown for interface state toggling
- usernetctl command for general network configuration
Creating Interface Configuration Files
For legacy systems, use /etc/sysconfig/network-scripts/ifcfg-<interface>. For example:
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
Restarting Networking Services
Restart services with:
sudo systemctl restart network
Validating the Setup
Verify with:
ip addr show dev eth0
Configuring Static IPs on Slackware Distributions
in Slackware distributions, the system startup goes through the /etc/rc.d network file framework, which includes /etc/rc.d/rc.inet1 (which ensures that the network is active), /etc/rc.d/rc.inet1.conf (which sets the properties of interfaces), and /etc/rc.d/rc.inet2.
Disabling Network Managers
The services of NetworkManager can be disables with the following command:
$ /etc/rc.d/rc.networkmanager stop $ chmod -x /etc/rc.d/rc.networkmanager
Editing Interface Configurations
Update /etc/rc.d/rc.inet1.conf with:
IFNAME[0]="eth0"
IPADDR[0]="192.168.1.100"
NETMASK[0]="255.255.255.0"
GATEWAY="192.168.1.1"
Restarting Network Services
Restart network services with:
sudo /etc/rc.d/rc.inet1 restart
Setting Up a Static IP on Gentoo
Adding Configuration for Network Interfaces
We need to modify /etc/conf.d/net with:
config_eth0="192.168.1.100/24"
routes_eth0="default via 192.168.1.1"
To control the interface, we need to create a script names accordingly:
$ ln --symbolic /etc/init.d/net.lo /etc/init.d/net.eth0
Restarting Network Interfaces
Restart the interface with:
sudo /etc/init.d/net.eth0 restart
Configuring Static IPs on Arch Linux
In Arch Linux, use netctl or systemd's networkd to configure static IPs. An example configuration for netctl in /etc/netctl/ might look like:
Interface=eth0
Connection=ethernet
IP=static Address=('192.168.1.100/24')
Gateway='192.168.1.1'
DNS=('8.8.8.8')
Activate with:
sudo netctl start <profile-name>
Conclusion
Configuring a static IP address on Linux ensures predictable network behavior. While temporary methods are straightforward for quick tasks, permanent setups require modifications to system files or network managers. With this guide, you can confidently implement static IP configurations across various Linux distributions.