Linux IP Configuration Guide: Setting IPv4 and IPv6
Managing both IPv4 and IPv6 configurations is an essential skill for Linux system administrators and developers. IPv4 remains the dominant addressing scheme in many environments, while IPv6 is increasingly used in modern infrastructures due to its vastly larger address space.
Whether deploying a local server, configuring edge devices, or supporting cloud-native platforms such as O-RAN infrastructure, reliable IP configuration is a fundamental requirement for network communication.
๐ Identify Your Network Interface #
Before configuring IP addresses, you must determine the name of the network interface you want to configure. Modern Linux systems typically use predictable interface names such as enp0s3, ens33, or eth0.
You can list all network interfaces using:
ip addr show
Alternatively, the legacy command can still be used on many systems:
ifconfig -a
These commands display available interfaces along with their current IP addresses and operational status.
๐ Configuring IPv4 Addresses #
IPv4 addresses can be configured either temporarily (runtime only) or permanently through configuration files.
Temporary Configuration #
Temporary settings are useful for testing because they remain active only until the system reboots.
Example:
sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0
This command assigns the IPv4 address 192.168.1.10 to the eth0 interface with a /24 subnet mask.
Permanent Configuration (Debian / Ubuntu) #
To make the configuration persistent across reboots, edit the network configuration file:
sudo nano /etc/network/interfaces
Add a configuration block similar to the following:
auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
This defines a static IPv4 configuration for the interface.
๐ Configuring IPv6 Addresses #
IPv6 uses 128-bit addressing, providing a much larger address space compared to IPv4. It is widely adopted in modern networking environments, including large-scale cloud platforms and telecommunications infrastructure.
Temporary IPv6 Configuration #
You can assign an IPv6 address at runtime using:
sudo ifconfig eth0 inet6 add 2001:0db8:85a3:0000:0000:8a2e:0370:7334/64
This assigns the specified IPv6 address with a /64 prefix to the interface.
Permanent IPv6 Configuration #
Persistent IPv6 settings can also be added to the /etc/network/interfaces file.
Example:
iface eth0 inet6 static
address 2001:0db8:85a3:0000:0000:8a2e:0370:7334
netmask 64
This configuration ensures the IPv6 address is automatically applied during system startup.
โ Applying and Verifying Configuration #
After modifying configuration files, restart the networking service to apply the changes.
sudo systemctl restart networking
To verify the configuration, inspect the interface details:
ip addr show eth0
Within the output:
inetentries represent IPv4 addressesinet6entries represent IPv6 addresses
This confirms that both protocol stacks are active on the interface.
๐ Troubleshooting and Useful Commands #
| Scenario | Command |
|---|---|
| Test IPv4 connectivity | ping -c 4 8.8.8.8 |
| Test IPv6 connectivity | ping6 -c 4 2001:4860:4860::8888 |
| Bring interface online | sudo ifup eth0 |
| Enable interface manually | sudo ip link set eth0 up |
Note that many modern Linux distributionsโsuch as Ubuntu 18.04+ and RHEL 8+โuse tools like Netplan or NetworkManager (nmcli) instead of /etc/network/interfaces.
๐ Modern Networking Considerations #
When configuring IP addresses in cloud or shared environments, additional network policies may affect connectivity.
Administrators should verify:
- Firewall rules (
ufw,iptables) - Security group policies in cloud platforms
- Routing configuration for IPv4 and IPv6 networks
Ensuring both protocol stacks are properly allowed through the network infrastructure is essential for reliable communication.
๐ Conclusion #
Linux provides flexible tools for managing network configuration across both legacy and modern systems. While ifconfig remains familiar to many administrators, the Linux ecosystem increasingly favors the ip command suite for advanced networking tasks.
Understanding how to configure both IPv4 and IPv6 ensures compatibility with a wide range of environmentsโfrom traditional on-premise systems to modern distributed infrastructure.