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.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF