Bobcares

How to Configure a Static IP Address in Ubuntu 24.04

by | Aug 11, 2024

Learn how to configure a Static IP Address in Ubuntu 24.04. Our Server Management Support team is here to help you with your questions and concerns.

How to Configure a Static IP Address in Ubuntu 24.04

Ubuntu 24.04 LTS is a feature-rich release from Ubuntu.

Once we install it, we have to set up the network interface.

By default, Ubuntu usually uses DHCP to automatically obtain an IP address. However, there are situations where setting up a static IP address is preferable, especially for network management and server operations.

A static IP address remains constant across system reboots, ensuring reliable remote access and supporting services dependent on fixed IPs. This is important in larger or more complex networks. However, we have to be careful while managing static IPs properly to prevent IP collisions.

What are IP Address Collisions

An IP address collision is a result of two devices on the same network being assigned the same IP address. This disrupts their ability to communicate.

While DHCP-managed networks minimize collision risks by dynamically assigning unique IPs, the introduction of static IP addresses can inadvertently lead to collisions. To avoid this, it’s important to allocate static and dynamic IP addresses in separate, non-overlapping ranges.

Why Use a Static IP Address?

Here are some of the benefits of using a static IP address:

  • Static IPs offer a fixed address for servers and devices, making network management and monitoring easier.
  • Devices with static IPs can be accessed remotely without worrying about address changes, ensuring consistent access to network resources.
  • Services that require specific IPs can be configured once, reducing the complexity of setup and maintenance.
  • Web and Mail Servers require consistent IP addresses for DNS resolution and reliable communication, ensuring website availability and email delivery.
  • Static IPs enable secure and reliable connections for users accessing VPNs or remote services.
  • Devices like printers and IoT systems benefit from static IPs to maintain consistent service without disruptions.
  • It allows administrators to restrict access to known IPs, reducing unauthorized access risks.
  • Static IPs make it easier to track network traffic and detect suspicious activities.
  • It also enables precise control over traffic, protecting systems from potential threats.

How to Configure a Static IP Address on Ubuntu 24.04

In Ubuntu 24.04, we can set a static IP address via the Graphical User Interface (GUI) and the Command Line Interface (CLI). Today, we will take a look at both these methods.

1. GUI Method

Ubuntu 24.04 uses GNOME as its default desktop environment. This offers an interface for managing network settings. Here’s how to configure a static IP address on our Ubuntu desktop:

  1. To begin with, click on the network icon in the top right corner of the screen.
  2. Then, click the `>` icon next to the Wired or Wireless connection.

    How to Configure a Static IP Address in Ubuntu 24.04

  3. Now, select the `(Wired) Settings` option to view current network details.
  4. Next, head to the settings menu, and go to the IPv4 tab.
  5. Then, toggle the IPv4 Method to Manual.
  6. Now, enter the desired IP address, netmask (usually `255.255.255.0`), and gateway.
  7. At this point, we can add DNS servers if necessary.
  8. Then, click the Apply button to save the settings.
  9. Now, wait for the system to apply the changes. We can verify the updated IP address in the details tab.

2. CLI Method

If you prefer the command line or are working on a server without a GUI, we can easily configure a static IP via the command line.

Before we begin, here are the requirements

  • A machine running Ubuntu 24.04.
  • Administrative (sudo) privileges.

Now, let’s take a look at the steps:

  1. To begin with, we have to first identify the network interface we are configuring:

    $ nmcli d

    This command lists all network interfaces. We have to note the interface name we plan to configure, such as `enp0s3`.

  2. Now, we have to edit the Netplan Configuration File. The Netplan configuration files are stored in `/etc/netplan/`.

    We may find files like `01-netcfg.yaml` or `50-cloud-init.yaml`. So, open the correct file for editing:

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

    Here’s an example configuration for setting a static IP address:

    network:
    version: 2
    renderer: networkd
    ethernets:
    enp0s3:
    dhcp4: no
    addresses:
    - 192.168.1.10/24
    routes:
    - to: default
    via: 192.168.1.1
    nameservers:
    addresses: [8.8.8.8, 8.8.4.4]

    Remember to replace enp0s3 with the interface name. Also, replace the IP address, subnet mask, default gateway, and DNS servers as necessary.

  3. Then, make sure the Netplan configuration file is secure to prevent unauthorized access:

    $ sudo chmod 600 /etc/netplan/01-netcfg.yaml

  4. Now, apply the changes to update the network settings:

    $ sudo netplan apply

    If there are no errors, the system will use the configured static IP address.

  5. Next, confirm the static IP has been assigned to our network interface:

    $ ip a

    This command displays all network interfaces and their configurations. Check the interface to verify the static IP assignment.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Setting a static IP address on Ubuntu 24.04 involves identifying the correct network interface, editing the Netplan configuration file, securing file permissions, and applying the changes. This process ensures that our server maintains consistent and secure network communication.

In brief, our Support Experts demonstrated how to configure a Static IP Address in Ubuntu 24.04.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.