How to Set Up a Static IP on Ubuntu 24.04 Server Edition

Last update: 05-11-2024

Configuring a static IP address on a server is crucial for maintaining a consistent network identity, ensuring reliable remote access, and supporting network services that depend on fixed IP addresses.

While indispensable in larger or more complex networks, static IPs must be managed carefully to avoid the risk of IP collisions.

This guide will walk you through the process of setting up a static IP on Ubuntu 24.04 Server Edition, ensuring that you implement this essential configuration without introducing errors.

Understanding IP Address Collisions

An IP address collision occurs when two devices on the same network are mistakenly assigned the same IP address, which can prevent both devices from communicating effectively on the network. In networks fully managed by DHCP, the risk of collisions is extremely low. However, the introduction of static IP addresses introduces a risk of collisions because DHCP servers do not recognize devices configured with static IPs and may inadvertently assign these addresses to other devices. To prevent such collisions, it is crucial to ensure that static and dynamic IP addresses are allocated in distinct, non-overlapping ranges.

Step 1: Access Your Router's Management Page

Open a web browser and navigate to your router's management page. Common addresses are:

however, this can vary depending on the manufacturer.

Step 2: Log In to Router Settings

Log in with your credentials. These are crucial for accessing and modifying your network settings.

Step 3: Modify DHCP Settings

Navigate to the DHCP settings usually found under "Local Network" and note the range of IP addresses your DHCP is configured to use.

Step 4: List Network Interfaces on Ubuntu

List all network interfaces:

ip a

Identify which interface you wish to configure with a static IP.

Step 5: Understanding Ubuntu's Network Management

Ubuntu uses netplan to configure network interfaces. The server edition of Ubuntu typically uses netplan with systemd-networkd as a renderer.

Change directory to Netplan's configuration directory and list the files:

cd /etc/netplan
ls

By default, only one file will be in the folder:

Step 6: Edit Netplan Configuration

Edit the netplan configuration file:

sudo nano 50-cloud-init.yaml

Replace the existing content with the following configuration (the full documentation can be found on ReadTheDocs):

network:
    version: 2
    renderer: networkd
    ethernets:
        net-if-name:
            addresses:
            - X.X.X.X/24

Important:

Step 7: Apply the Configuration

Test your new configuration:

sudo netplan try

If everything works as expected, apply it permanently:

sudo netplan apply

After these steps, your Ubuntu server will have a static IP address, reducing uncertainties and making server and network management easier.

StocksComparison.com ad

4 Comments

Add a new comment: