Quick Guide to Setting a Temporary Static IP Address in Linux

watch 5m, 7s
views 2

08:23, 21.04.2026

Article Content
arrow

  • Introduction
  • Understanding Dynamic vs Static IP Addresses
  • Configuring a Static IP on Linux
  • Viewing Current Network Settings
  • Evaluating the Role of DHCP
  • Setting a Temporary Static IP Using the ip Command
  • Establishing a Permanent Static IP with the ip Command
  • Managing Network Tools
  • Detecting Installed Network Managers
  • Controlling Network Managers Effectively
  • Setting a Static IP on Debian-Based Systems
  • Adding Interface Configurations
  • Restarting the Network or Specific Interfaces
  • Verifying the Configuration
  • Configuring a Static IP on Red Hat and RPM-Based Systems
  • Using network-scripts and NetworkManager
  • Creating Interface Configuration Files
  • Restarting Networking Services
  • Validating the Setup
  • Configuring Static IPs on Slackware Distributions
  • Disabling Network Managers
  • Editing Interface Configurations
  • Restarting Network Services
  • Setting Up a Static IP on Gentoo
  • Adding Configuration for Network Interfaces
  • Restarting Network Interfaces
  • Configuring Static IPs on Arch Linux
  • Conclusion

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.

Share

Was this article helpful to you?

VPS popular offers

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
150 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-KVM-SSD 16384 Linux

231 /mo

/mo

Billed annually

-8.1%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
Unlimited
wKVM-HDD 8192 Windows

31.25 /mo

/mo

Billed annually

-9.3%

CPU
CPU
6 Epyc Cores
RAM
RAM
16 GB
Space
Space
150 GB NVMe
Bandwidth
Bandwidth
Unlimited
wKVM-NVMe 16384 Windows

54.49 /mo

/mo

Billed annually

-8.4%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
75 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-wKVM-SSD 2048 Windows

37.4 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
MT5 KVM 4096 Windows

19.99 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Epyc Cores
RAM
RAM
8 GB
Space
Space
100 GB NVMe
Bandwidth
Bandwidth
Unlimited
KVM-NVMe 8192 Linux

26.35 /mo

/mo

Billed annually

-10%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
400 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 16384 Linux

50 /mo

/mo

Billed annually

-10%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
50 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 4096 Linux

15.95 /mo

/mo

Billed annually

-9.7%

CPU
CPU
10 Xeon Cores
RAM
RAM
64 GB
Space
Space
300 GB SSD
Bandwidth
Bandwidth
Unlimited
wKVM-SSD 65536 Windows

138.99 /mo

/mo

Billed annually

-15%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
80 Mbps
DDoS Protected SSD-wKVM 8192 Windows

101 /mo

/mo

Billed annually

Other articles on this topic

cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.