How to configure a static IP address on Debian, Arch, Ubuntu, openSUSE, and Fedora

Last update: 17/09/2025
Author Isaac
  • Identify who manages the network (NetworkManager, wicked, or systemd-networkd) before applying changes.
  • Choose the appropriate method per distro: nmcli/nmtui, ifcfg/interfaces, netplan, or netctl profiles.
  • Configure DNS where appropriate (profile or resolv.conf) and verify routes with ip route.

Guide to configuring a static IP address on Linux

Configure a fixed IP in Linux It's not complicated, but there are important nuances depending on the distribution and the network manager in use. On computers with a graphical environment, this can be done in two clicks; however, when working on servers, in minimalist environments, or wanting to automate, the line of commands offers precision, repeatability and total control.

In this guide we unify the best of several proven methods: classic configuration files, NetworkManager with nmcli/nmtui, Arch-specific tools such as netctl or own systemd-networkd, and specifics of Debian/Ubuntu, Fedora/RHEL, and openSUSE. We also review DNS, verification, and good practices to avoid conflicts.

Prerequisites and basic checks

Before you touch anything, it's a good idea to identify the actual name of the network interface: on older systems you'll see eth0/wlan0, while in modern it is common enp2s0/eno1/wlp1s0This predictable nomenclature avoids surprises when changing hardware.

To list interfaces in detail use ip (preferred today over ifconfig):

ip addr
ip -c link show    # salida coloreada

If you need the classic utility, install net-tools and run ifconfig at your own discretion:

sudo apt install net-tools
sudo ifconfig

With NetworkManager you can see connections and devices with nmcli very comfortably:

nmcli connection show
nmcli device status

A useful tip: if you are going to set an IP on your home LAN, check that it is not occupied by a ping the candidate address (replace xxx) and if you don't know how to locate the gateway, consult find the IP, gateway and DNS:

sudo ping 192.168.0.xxx

If "Destination Host unreachable«, normally that IP does not respond and you can assign it collision-free. If it returns response times, it's already being used by another computer.

Commands to view and configure the network in Linux

NetworkManager: nmcli and nmtui (applicable to Debian, Ubuntu, Fedora, openSUSE, etc.)

In most modern distributions, NetworkManager governs connectionsWith nmcli, you can view overall status and activate/deactivate profiles on the fly, without opening the editor.

Status and connections available with a few commands:

nmcli general status
nmcli connection show
nmcli device status

Assigning a static IP by modifying an existing profile (set name, interface and IP):

sudo nmcli connection modify "eth0" \
  ipv4.method manual ip4 192.168.1.20/24 \
  gw4 192.168.1.101 ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli connection up "eth0"

Creating a new profile with a fixed IP and activating it is just as straightforward and avoid touching files by hand:

sudo nmcli connection add type ethernet ifname eth0 con-name static-ip \
  ip4 192.168.1.100/24 gw4 192.168.1.1
sudo nmcli connection modify static-ip ipv4.dns "8.8.8.8 1.1.1.1" ipv4.method manual
sudo nmcli connection up static-ip

Wi-Fi from CLI: list networks and connect indicating SSID and password with a single order:

nmcli device wifi list
sudo nmcli device wifi connect NOMBRE_SSID password TU_CONTRASEÑA

Advanced editing and cleaning of profiles with nmcli:

nmcli connection edit NOMBRE_DEL_PERFIL
sudo nmcli connection delete NOMBRE_DEL_PERFIL

If you prefer a text-based interface, install and launch nmtui (very useful on servers):

# Fedora/RHEL
sudo dnf install NetworkManager-tui
sudo nmtui

Debian and derivatives (including Ubuntu): /etc/network/interfaces, NM and netplan

In classic Debian you can set the IP by editing / etc / network / interfaces. Note: If NetworkManager is installed and managing the interface, will ignore whatever you put in that fileIn that case, uninstall it or mark the interface as not managed by NM.

  Fix: "Please insert Windows recovery media or installation media" error

To avoid conflicts, in purely static scenarios many administrators choose to remove NetworkManager and its dependencies:

sudo apt remove network-manager
sudo apt autoremove

File /etc/network/interfaces with fixed IP in, for example, enp2s0:

# The loopback network interface
auto lo
iface lo inet loopback

# Interfaz principal
auto enp2s0
allow-hotplug enp2s0
iface enp2s0 inet static
  address 192.168.1.150
  netmask 255.255.255.0
  gateway 192.168.1.101
  dns-nameservers 9.9.9.9 8.8.8.8

For DHCP it is enough to declare the method dhcp and ready:

auto enp2s0
allow-hotplug enp2s0
iface enp2s0 inet dhcp

Apply changes by restarting the network service on Debian-based systemd systems: rápido y seguro.

sudo systemctl restart networking.service

Key details from the interfaces file that should know to avoid losing control of the network:

  • auto: interfaces that come up with ifup -a (in the Boot).
  • Allow-Uuto: equivalent to auto with ifup –allow=auto.
  • allow-hotplug: rise on hotplug events (cable, kernel detection).
  • iface: defines the logical configuration (inet/inet6 and loopback/dhcp/static).
  • Static options: address, netmask, gateway, network, broadcast, hwaddress.
  • Hooks: pre-up, up, post-up, pre-down, down, post-down (can be repeated; add “|| true” if you want them not to interrupt).
  • Comments with # and line extension with \ when you need to split configuration.

About DNS: Editing /etc/resolv.conf by hand may not persist if you manage it resolvconf or NetworkManager; in pure Debian it usually works, but the cleanest way is to define DNS in interfaces or in the tool that manages the networkIf you are concerned about privacy, see how hide your IP address.

Modern Ubuntu uses netplan (YAML in /etc/netplan/*.yaml) to define the network with NetworkManager or systemd-networkd; if you don't see any results with interfaces on your Ubuntu server, consider applying netplan apply after editing your file instead of the classic method.

RPM (Fedora, Rocky/Alma, CentOS): ifcfg, nmcli and nmtui

In the RHEL/CentOS family there were traditionally files /etc/sysconfig/network-scripts/ifcfg-INTERFACEAlthough NetworkManager is the newer Fedora, these ifcfgs are still common in derivatives like Rocky/Alma.

Example of a static file for an interface enp0s2 on RHEL/derivative type systems:

TYPE="Ethernet"
BOOTPROTO="none"
DEFROUTE="yes"
IPV6INIT="yes"
NAME="enp0s2"
ONBOOT="yes"
HWADDR="08:00:27:80:63:19"
IPADDR0="192.168.225.150"
PREFIX0="24"
GATEWAY0="192.168.225.1"
DNS1="8.8.8.8"

After saving, restart the network service if you are using the classic stack; check with ip addr that everything is in its place:

sudo systemctl restart network
ip addr

With NetworkManager active, nmcli/nmtui is the recommended route. Modify profiles, activate the connection, and, if necessary, restart NetworkManager:

sudo nmcli connection modify "eth0" \
  ipv4.method manual ip4 192.168.1.20/24 \
  gw4 192.168.1.101 ipv4.dns "8.8.8.8"
sudo nmcli connection up "eth0"
sudo systemctl restart NetworkManager

openSUSE: NetworkManager or wicked (sysconfig)

In openSUSE you can operate with NetworkManager (nmcli/nmtui) or with wicked and its sysconfig format. If you're using NM, apply the exact same nmcli commands as in the previous section.

  Repair: Unable to Open Contacts on Android Cellphone

With wicked, the configuration per interface resides in /etc/sysconfig/network/ifcfg-NAMEA typical example for static IP in, say, eth0 would:

BOOTPROTO='static'
STARTMODE='auto'
IPADDR='192.168.1.50/24'
GATEWAY='192.168.1.1'
DNS1='1.1.1.1'
DNS2='8.8.8.8'

Apply changes by restarting wicked and check routes and IP with IP addr e ip route:

sudo systemctl restart wicked
ip addr
ip route | grep default

Arch Linux: netctl and systemd-networkd

Arch offers several routes. With netctl You can copy a sample profile and adapt it to your interface. This is a very useful option for lightweight servers.

Profile your static connection from the examples and enable it to start automatically with systemd:

ls /etc/netctl/examples/
sudo cp /etc/netctl/examples/ethernet-static /etc/netctl/enp2s0
sudo nano /etc/netctl/enp2s0
# Contenido recomendado:
Description='A basic static ethernet connection'
Interface=enp2s0
Connection=ethernet
IP=static
Address=('192.168.1.102/24')
Gateway=('192.168.1.1')
DNS=('8.8.8.8' '8.8.4.4')

sudo netctl enable enp2s0
sudo netctl start enp2s0

If you were using dhcpcd, stop and disable it to prevent it from overwriting your newly defined static IP and thus maintain the network without interference:

sudo systemctl stop dhcpcd
sudo systemctl disable dhcpcd

The second path in Arch is systemd-networkd, minimalist and solid. Create a .network profile and activate the service:

sudo nano /etc/systemd/network/enp2s0.network
# Ejemplo:

Name=enp2s0


Address=192.168.1.102/24
Gateway=192.168.1.1
DNS=8.8.8.8
DNS=8.8.4.4

# Desactiva netctl si estaba en uso
aur: sudo systemctl disable netctl@enp2s0.service
# Asegúrate de que dhcpcd no interfiera
aur: sudo systemctl stop dhcpcd && sudo systemctl disable dhcpcd
# Activa systemd-networkd
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd

After reboot, check with IP addr that your address and routes are operational; if not, check the interface name, mask and Gateway.

DNS Servers: Selection and Configuration

You can declare DNS in the connection itself (nmcli, netplan or interfaces) or edit / Etc / resolv.conf if it is not managed by another tool. Remember that some systems write "DO NOT EDIT THIS FILE BY HAND» because it is generated by resolvconf/NetworkManager.

Simple example of resolv.conf when there is no manager on it and you want to force it by hand with two servers and search domains:

nameserver 1.1.1.1
nameserver 8.8.8.8
search midominio.local otrodominio.local

List of known public DNS so you can choose based on performance or filtering and privacy policy, with primary and secondary:

  • Quad9 (IBM): 9.9.9.9
  • OpenDNS: 208.67.220.123 / 208.67.220.222 / 208.67.220.220
  • Cloudflare: 1.1.1.1 / 1.0.0.1
  • Level3: 209.244.0.3 / 209.244.0.4
  • Verisign: 64.6.64.6 / 64.6.65.6
  • Google: 8.8.8.8 / 8.8.4.4
  • WATCH: 84.200.69.80 / 84.200.70.40
  • Comodo Secure DNS: 8.26.56.26 / 8.20.247.20
  • OpenDNS Home: 208.67.222.222 / 208.67.220.220
  • DNS Advantage: 156.154.70.1 / 156.154.71.1
  • Norton ConnectSafe: 199.85.126.10 / 199.85.127.10
  • SafeDNS: 195.46.39.39 / 195.46.39.40
  • OpenNIC: 50.116.23.211 / 107.170.95.180
  • SmartViper: 208.76.50.50 / 208.76.51.51
  • Dyn: 216.146.35.35 / 216.146.36.36
  • FreeDNS: 37.235.1.174 / 37.235.1.177
  • Alternate DNS: 198.101.242.72 / 23.253.163.53
  • Yandex DNS: 77.88.8.8 / 77.88.8.1
  • puntCAT: 109.69.8.51
  PcComponentes launches PcCloud, its new cloud storage service with advanced security.

Remember that the first DNS is the preferred one and the second acts as automatic backupIf you want to inspect specific resolutions, nslookup or dig will tell you which IP addresses a domain returns:

nslookup google.com

Verification, routes and network service

After applying changes check your IP, mask and broadcast with IP addr; there should be no doubt about the status of the interface or whether it is UP or DOWN.

ip addr

Check the default gateway with the routing table; if there is no default gateway, your computer will not be able to access the Internet even if it has one. Correct static IP. If you detect errors such as Ethernet does not have a valid IP configuration, check interface, mask and gateway:

ip route | grep default

For detailed information with NetworkManager, nmcli device show It's gold: it shows active IPv4, gateway and DNS:

nmcli device show

In some minimalist environments you may not have reboot/shutdown installed; with systemd you can restart or shut down likewise:

sudo systemctl reboot
sudo systemctl poweroff

If you find that your manual configuration isn't working in Debian because NM is still in control, check whether you should uninstall it or migrate to nmcli control. In Ubuntu, consider netplan, and on openSUSE it validates whether you use NetworkManager or wicked before applying changes, so the configuration will persist without surprises.

With all of the above, you have at hand both the classic methods and modern tools to set an immutable IP in Debian/Ubuntu, Fedora/RHEL, openSUSE, and Arch. Choosing the right path (nmcli/nmtui, system files, or services like netctl/systemd-networkd) depends on who manages the network in your distro, but the result is the same: stability, control and zero surprises when managing demanding servers and desktops.

what is the default username and password for routers-0
Related article:
How IP Address, MAC Address, and Netmask Work