How To Configure Static IP Address On Ubuntu In 2024 How To Configure Static IP Address On Ubuntu In 2024

How To Configure Static IP Address On Ubuntu In 2024

Configure Static IP Address On Ubuntu & It’s Derivatives

There are multiple ways to configure static IP address on Ubuntu and it’s derivatives like Lubuntu, Xubuntu, Ubuntu Budgie and so on. Let’s have a look into the step by step guide to configure static ip address on Ubuntu.

How To Configure Static IP Address On Ubuntu In 2024

Method 1:

1. Configuring Static IPv4 Address on Ubuntu with CLI

Run the following command to  find out the network interface name in your system:

sudo ip a

Now, you need to create or edit the network configuration file under the /etc/netplan directory.  Ubuntu uses the Netplan as a network manager that is responsible for configuring the network interfaces in Ubuntu. Now Create a configuration file and edit it in an editor:

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

Add the network configuration in YAML format as below:

 

  • Locate the line that corresponds to your network interface (e.g., eth0) and modify it to include the static IP configuration. Replace the existing content with something similar to the following, adjusting the values according to your network configuration:
  • auto eth0
    iface eth0 inet static
    address 192.168.1.2 # Replace with your desired static IP
    netmask 255.255.255.0 # Replace with your subnet mask
    gateway 192.168.1.1 # Replace with your gateway IP
    dns-nameservers 8.8.8.8 8.8.4.4 # Replace with your DNS servers
  • Save the file and exit the text editor.
  • Restart the networking service to apply the changes:bash
sudo service networking restart

Leave a Reply

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