Logo

How to Configure Static IP Address on Ubuntu Server 24.04

Mar 14, 2024

To configure a static IP address on your Ubuntu Server 24.04, follow the steps below:

Step 1 : First, ensure your system is up to date and install the net-tools package, which includes the ifconfig command:

sudo apt update
sudo apt install net-tools

Step 2 : Check the list of Ethernet interfaces to identify the one you want to configure:

ifconfig -a

Step 3 : Open the netplan configuration file for editing:

sudo nano /etc/netplan/50-cloud-init.yaml

Step 4 : Add the following configuration snippet to assign a static IP address to your chosen Ethernet interface (replace "ensX" with your actual interface name and adjust the IP address, netmask, gateway, and DNS servers as needed):

network:
    ethernets:
        enp0s3:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.1.30/24]
            routes:
                - to: default
                  via: 192.168.1.1
            nameservers:
                  addresses: [ "8.8.8.8", "8.8.4.4" ]
    version: 2

Step 5 : Apply the changes to the netplan configuration:

sudo netplan apply

Step 6 : Verify that the static IP address is configured correctly by pinging a reliable external host, such as Google:

ping google.com

Congratulations! You have successfully configured a static IP address on your Ubuntu Server 24.04.

Recommended