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:
network:<br />
version: 2<br />
renderer: networkd<br />
ethernets:<br />
eth0:<br />
addresses:<br />
- 192.168.1.212/24<br />
nameservers:<br />
addresses: [8.8.8.8, 8.8.4.4]<br />
routes:<br />
- to: default<br />
via: 192.168.1.2
Apply the changes by running the following commands. The static IP address is configured on your Ubuntu system.
sudo netplan apply
Method 2:
Configuring Static IPv4 Address on Ubuntu using GUI
In this method, we will configure static IPv4 address through GUI method.
- Click the network icon in the upper-right corner of your Ubuntu desktop environment
- Then you need to expand the Wired Connected dropdown.
- Now, click on Wired Setting.
- A network settings dialog box will popup
- Click “Network” in left sidebar.
- Under the Wired section, click the Gear icon
- A new Wired Window configuration box will appear.
- Click on “IPv4” tab.
- Set IPv4 Method to Manual mode
- Input a valid IP address, Netmark and Gateway address
- Set the DNS server (this setting is optional)
- Click Apply button to save the changes that you have made.
- Now you need to disable and then again enable networking to apply changes.
Method 3:
3. Using /etc/network/interfaces (Ubuntu 16.04 and earlier)
- Open the network interfaces file using a text editor:
- sudo nano /etc/network/interfaces
- 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