Posted on
Operating Systems

Configuring Static IP Addresses on Each Distro

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

How to Configure Static IP Addresses on Major Linux Distributions

Navigating network setup in Linux can be a bit daunting, especially if you're new to different distributions and their unique methods of handling configurations like setting a static IP address. This tutorial will break down the steps required to configure static IP addresses in some of the most popular Linux distros: Ubuntu, Fedora, and Debian. By the end of this guide, you'll understand how to set up a stable and reliable network configuration tailored to your needs.

1. Configuring Static IP in Ubuntu

Ubuntu uses Netplan for network configuration in its recent releases (17.10 onwards). Netplan is a utility that reads YAML description files to configure network interfaces.

Here are the steps to set a static IP on Ubuntu:

Step 1: Find Your Network Interface Name

First, you need to know the interface name that you want to configure. Open a terminal and type:

ip link show

Identify your network interface from the displayed list, typically named something like ens33 or eth0.

Step 2: Edit Netplan Configuration

Netplan's configuration files can usually be found in /etc/netplan/. For a default installation, you should see a file named 01-netcfg.yaml. Open this file in a text editor with sudo privileges:

sudo nano /etc/netplan/01-netcfg.yaml

Step 3: Configure Static IP

Modify the file to set your static IP. Here is an example configuration:

network:
  version: 2
  ethernets:
    ens33:
      dhcp4: no
      addresses:
        - 192.168.1.100/24
      gateway4: 192.168.1.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 8.8.4.4

Replace ens33 with your interface name, and adjust the addresses, gateway4, and nameservers fields per your network requirements.

Step 4: Apply Configuration

Apply the changes with:

sudo netplan apply

If you encounter any issues, you can diagnose with sudo netplan --debug apply.

2. Configuring Static IP in Fedora

Fedora uses NetworkManager and nmcli or the nmtui tool (a text user interface).

Step 1: Open nmtui

You can easily configure static IP using nmtui:

sudo nmtui

Step 2: Edit a Connection

Select “Edit a connection” and choose your network interface. Set IPv4 Configuration to Manual, and then enter your IP address, gateway, netmask, and DNS.

Step 3: Restart NetworkManager

Restart the NetworkManager to apply changes:

sudo systemctl restart NetworkManager

3. Configuring Static IP in Debian

Debian also uses the interfaces file located in /etc/network/interfaces for older versions or Netplan in newer releases (similar to Ubuntu).

Step 1: Edit /etc/network/interfaces

On older systems, you simply need to edit this file using:

sudo nano /etc/network/interfaces

And add the following (assuming your interface is eth0):

auto eth0
iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1
nameserver 8.8.8.8 8.8.4.4

Step 2: Restart Networking Service

To apply changes, restart the networking service:

sudo /etc/init.d/networking restart

For Debian versions using Netplan, follow the Ubuntu steps detailed above.

Conclusion

While the network configuration process can slightly vary between different Linux distributions, understanding how to manually configure your network interfaces is crucial. This guide covers fundamental procedures that you can customise further according to your specific network settings. Whether you're setting up a home lab, a server, or your workstation, mastering IP configuration is an essential skill.