This article will help you to configure static IPv4 addresses on Ubuntu systems using the Netplan command-line tool.
Check the Network Interface Name
First of all, you need to identify the network interface name. It can differ based on the installation type and system environment.
To find the interface name type:sudo nmcli device status Output: DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired connection 1 lo loopback unmanaged – You can also check the interface name using the ip command:sudo ip a Checking the network interface name
The above output shows that the system is configured with the network interface name eth0. This can be different on your system. So please verify the system network interface name with the ip a command as shown above.
Configuring the Static IP Address using Netplan
Netplan stores all the configuration files under /etc/netplan directory. As you already have the network interface name found in the above commands. Now, we will configure the static IP address to that interface using the NetPlan utility. Let’s, create a configuration file and edit it in your favorite text editor: Add the network configuration in YAML format. The below configuration uses 4 spaces due to strict indentation followed by the YAML. In the above configuration:
eth0 – is the network interface name 192.168.0.210/24 – is the IPv4 address to set on interface. Make sure to define CIDR. You can add multiple IP address as well. routes via 192.168.0.254 – Set the gateway IP address of the network 8.8.8.8, 8.8.4.4 – is the IP address of the Google DNS servers.
Make sure the IPv4 address belongs to the system network and has the correct gateway Ip address. Once confirmed, press ESC and :wq to save file content and close it. Now, execute the following command to apply the changes: This will configure the static IPv4 address on the network interface. Now the system will be accessible with the new IP address you configured above.
Conclusion
In this tutorial, you have learned to configure the network interface on Ubuntu systems.
title: “Configuring The Static Ipv4 Address On Ubuntu Using Netplan Tecadmin” ShowToc: true date: “2022-12-22” author: “Leslie Nakamura”
This article will help you to configure static IPv4 addresses on Ubuntu systems using the Netplan command-line tool.
Check the Network Interface Name
First of all, you need to identify the network interface name. It can differ based on the installation type and system environment.
To find the interface name type:sudo nmcli device status Output: DEVICE TYPE STATE CONNECTION eth0 ethernet connected Wired connection 1 lo loopback unmanaged – You can also check the interface name using the ip command:sudo ip a Checking the network interface name
The above output shows that the system is configured with the network interface name eth0. This can be different on your system. So please verify the system network interface name with the ip a command as shown above.
Configuring the Static IP Address using Netplan
Netplan stores all the configuration files under /etc/netplan directory. As you already have the network interface name found in the above commands. Now, we will configure the static IP address to that interface using the NetPlan utility. Let’s, create a configuration file and edit it in your favorite text editor: Add the network configuration in YAML format. The below configuration uses 4 spaces due to strict indentation followed by the YAML. In the above configuration:
eth0 – is the network interface name 192.168.0.210/24 – is the IPv4 address to set on interface. Make sure to define CIDR. You can add multiple IP address as well. routes via 192.168.0.254 – Set the gateway IP address of the network 8.8.8.8, 8.8.4.4 – is the IP address of the Google DNS servers.
Make sure the IPv4 address belongs to the system network and has the correct gateway Ip address. Once confirmed, press ESC and :wq to save file content and close it. Now, execute the following command to apply the changes: This will configure the static IPv4 address on the network interface. Now the system will be accessible with the new IP address you configured above.
Conclusion
In this tutorial, you have learned to configure the network interface on Ubuntu systems.