Welcome back to Linux Networking Mastery! In Part 1, we covered the fundamentals: the Linux network stack, core components like interfaces and routing tables, and basic inspection commands (ip link, ip addr, ip route, ping). If you haven't tried the quick exercise from that post, do it now—it will make everything here feel familiar.
Today we're taking the next step: actively managing network interfaces. We'll learn how to bring interfaces up and down, assign IP addresses temporarily, and—most importantly—make those changes persistent across reboots. We'll focus on modern tools while noting legacy alternatives, and we'll cover the major differences between Debian-based (Ubuntu, Debian) and RHEL-based (Fedora, CentOS, Rocky Linux) distributions.
By the end of this post, you'll be able to configure a static IP, switch to DHCP, or troubleshoot why an interface isn't coming up after a reboot.
The ip Command Suite: Your Primary Tool
The ip command from iproute2 is the modern, universal way to manage networking on Linux. It has replaced older tools like ifconfig and route. Everything we'll do here works the same on virtually all distributions.
Bringing Interfaces Up and Down
To administratively enable or disable an interface:
sudo ip link set dev enp0s3 up
sudo ip link set dev enp0s3 down
Replace enp0s3 with your interface name (find it with ip link show from Part 1).
Check status:
ip link show dev enp0s3
Look for the UP flag in <...>.
Assigning IP Addresses Manually (Temporary)
Add an IPv4 address:
sudo ip addr add 192.168.1.100/24 dev enp0s3
Remove it:
sudo ip addr del 192.168.1.100/24 dev enp0s3
For IPv6:
sudo ip addr add 2001:db8::100/64 dev enp0s3
To make the interface fully operational after adding an address, ensure it's up and has a route (often added automatically for directly connected subnets).
Flush all addresses (useful for testing):
sudo ip addr flush dev enp0s3
Note: These changes are temporary—they disappear on reboot or when the interface goes down.
DHCP Client (Temporary)
Most systems use dhclient or dhcpcd, but the modern way is often through your distro's network manager (covered below). For a quick manual DHCP request:
sudo dhclient enp0s3 # Releases and renews lease
sudo dhclient -r enp0s3 # Release only
Persistent Configuration: Making Changes Stick
This is where distributions diverge. Linux has several competing network management systems, and which one your system uses depends on the distro and version.
Debian/Ubuntu Family
Older method (/etc/network/interfaces – still works on many servers):
Edit /etc/network/interfaces:
sudo nano /etc/network/interfaces
Example for static IP:
auto enp0s3
iface enp0s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 1.1.1.1
iface enp0s3 inet6 static
address 2001:db8::100/64
gateway 2001:db8::1
For DHCP:
auto enp0s3
iface enp0s3 inet dhcp
Apply changes:
sudo ifdown enp0s3 && sudo ifup enp0s3
# Or reboot
Modern method (Ubuntu 18.04+, Debian 10+): Netplan
Netplan uses YAML files in /etc/netplan/.
Example /etc/netplan/01-netcfg.yaml:
network:
version: 2
renderer: networkd # or NetworkManager
ethernets:
enp0s3:
dhcp4: no
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
dhcp6: no
addresses:
- 2001:db8::100/64
For DHCP:
dhcp4: yes
dhcp6: yes
Apply:
sudo netplan apply
RHEL/Fedora/CentOS Family
Primary method: NetworkManager (default on desktops and most servers)
Use nmcli (command-line tool):
List connections:
nmcli connection show
Modify the active connection (often named "System enp0s3" or similar):
Static IPv4:
sudo nmcli con mod "System enp0s3" ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns "8.8.8.8 1.1.1.1"
sudo nmcli con up "System enp0s3"
DHCP:
sudo nmcli con mod "System enp0s3" ipv4.method auto ipv4.dns "8.8.8.8"
sudo nmcli con up "System enp0s3"
For IPv6, replace ipv4 with ipv6 (methods: auto for SLAAC/DHCPv6, manual for static).
Alternative: systemd-networkd (increasingly common on minimal/server installs)
Create /etc/systemd/network/10-enp0s3.network:
[Match]
Name=enp0s3
[Network]
DHCP=yes # or no for static
[Address]
Address=192.168.1.100/24
[Route]
Gateway=192.168.1.1
[DHCP]
UseDNS=yes
Enable and apply:
sudo systemctl enable --now systemd-networkd
sudo systemctl restart systemd-networkd
Legacy (RHEL 7/CentOS 7): /etc/sysconfig/network-scripts/ifcfg-enp0s3 files.
IPv4 vs. IPv6 Considerations
- IPv6 is enabled by default on modern kernels.
- Link-local addresses (
fe80::/10) are always auto-configured. - For full IPv6, you usually need router advertisements (SLAAC) or DHCPv6.
- Many examples above include both; disable IPv6 system-wide only if you have a specific reason (
sysctl net.ipv6.conf.all.disable_ipv6=1).
Hands-On Exercises
Temporary static IP
- Flush addresses on your main interface.
- Bring it down, then up.
- Assign a new IP in the same subnet as your current one (e.g., change the last octet).
- Ping your gateway to verify.
Switch to DHCP (if currently static)
- Use your distro's method to set the interface to DHCP.
- Apply and verify with
ip addr show.
Create a Netplan or nmcli static config
- Set a static IP different from your current one (safe for testing).
- Apply, reboot, and confirm it persists.
Safety tip: Do this on a VM or have console access—misconfiguring your only interface can lock you out remotely!
What's Next?
In Part 3, we'll dive deeper into routing: manipulating the routing table, adding static routes, policy routing, and even turning your Linux box into a simple router using multiple interfaces and network namespaces.