Advance

Set IP static on Ubuntu 20.04 LTS Server with netplan

Richard 7 Min Read
Set IP static on Ubuntu 20.04 LTS Server with netplan

[Updated on Date: 2021-01-30] A static IP is an IP address that is fixed and does not change. You can set it for your devices that use an IP address to be configured for having a static IP address. Since the network configuration is controlled and managed by netplan in Ubuntu 20.04, join us to review how to set IP static on ubuntu 20.04 LTS Server with netplan. Netplan enables configuring networking on a system via YAML files easily. And processes the YAML and generates the required configurations for either Network Manager or systemd-network the system’s renderer. To buy your own Linux VPS visit Eldernode and find the best suitable package due to your needs.

Recommended Article: How to install Apache Web Server on Debian 10

To let this tutorial work better, please consider the below Prerequisites:

A non-root user with sudo privileges.

To set up, follow our Initial server setup on Ubuntu 20.04.

Tutorial Set IP static on Ubuntu 20.04 LTS Server with netplan

Using netplan utility as a new command-line network configuration helps you to manage and configure network settings easily in Ubuntu systems.

How to check Interface name

In the first step, you need to check all interfaces on the Ubuntu 20.04 LTS server. Enter the below command for getting the Network Interface Controller name.

ip addr

When you enter the command, you can see your interface name. You need the name for network configuration later.

set ip static on ubuntu 20.04 lts server -1

 

How to Set the IP address on Ubuntu 20.04 server

Go to /etc/netplan directory and check the name of the YAML file.

cd /etc/netplan

After that, you can use the ls command to see the YAML file.

ls

It is time to set IP static on Ubuntu 20.04 LTS Server.

Sudo nano 00-installer-config.yaml

Remember: Do not forget to edit your yaml file.

Type your Static IP and other information like this

network       ethernets:         ens160:          dhcp4: no            addresses: [192.168.100.120/24]            gateway4: 192.168.100.1            nameservers:              addresses: [8.8.8.8, 1.1.1.1]          dhcp6: no       version: 2

Please attention below picture, you will see some space and some rules. If you do not consider rules, netplan can not detect your configuration.

After adding IP static and other information on the file, save, and exit.

Point: you can save and exit with Ctrl + x key and press Enter key twice.

set ip static on ubuntu 20.04 lts server -2

 

Apply configuration with the following command.

sudo netplan apply

Now you can check Network configuration by ping your IP or ip addr command.

set ip static on ubuntu 20.04 lts server -3

 

Also, you could see the video on the Eldernode Youtube channel.

 

 

Conclusion

In this article, you learned how to Set IP static on Ubuntu 20.04 LTS Server with netplan. From now on you can look at the bigger infrastructure by using the static IP to avoid network problems. In case you are interested in learning more, find our related article on How to find server public IP Address in Linux terminal.

View More Posts
Richard
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

23 thoughts on “Set IP static on Ubuntu 20.04 LTS Server with netplan

    1. You can have a look at our article on (https://blog.eldernode.com/set-static-ip-in-windows-server-2016/)
      But if i want to explain you, please trace below steps: Click Start Menu > Control Panel > Network and Sharing Center or Network and Internet > Network and Sharing Center. Then, click change adapter settings. After detecting your area connection, click properties and Select Internet Protocol Version Again Click Properties and select use the following IP address.

    1. Yes you need. Because the router is the gateway between the Internet and your home network. Also you should Access the router’s interface and lock it down.

    1. Dear user, let’s see this overview together. After selecting the settings of the network interface you wish to configure to use a static IP address, you need to click the settings icon to start configuration. And when you select IPv4 tab, then you will select manual and enter your desired static IP address, netmask, gateway and DNS settings.

    1. You can have a look at our article on (https://blog.eldernode.com/set-static-ip-in-windows-server-2016/)
      But if i want to explain you, please trace below steps: Click Start Menu > Control Panel > Network and Sharing Center or Network and Internet > Network and Sharing Center. Then, click change adapter settings. After detecting your area connection, click properties and Select Internet Protocol Version Again Click Properties and select use the following IP address.

    1. You can use the following commands to see all network interfaces under Linux operating systems:
      ip command – It is used to show or manipulate routing, devices, policy routing and tunnels.
      netstat command – It is used to display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
      ifconfig command – It is used to display or configure a network interface

    1. Since, Ubuntu has switched to Netplan for configuring network interfaces; Netplan is based on YAML based configuration system that makes configuration process very simple. Netplan has replaced the old configuration file /etc/network/interfaces which was used for configuring network interfaces in Ubuntu.

    1. Netplan is a new command-line network configuration utility introduced in Ubuntu 17.10 to manage and configure network settings easily in Ubuntu systems. It allows you to configure a network interface using YAML abstraction.

    1. In this case you should be aware that on a running system, netplan can be removed by installing ifupdown, configuring /etc/network/interfaces manually as users have done before and finally removing the netplan.io package altogether.

    1. To explain fast, please consider the 3 below steps to go for that:
      Run update command to update package repositories and get latest package information.
      Run the install command with -y flag to quickly install the packages and dependencies. sudo apt-get install -y ifupdown.
      Check the system logs to confirm that there are no related errors.

  1. You mentioned how to check Network configuration by ping your IP or ip addr command. Please explain how to assign a static IP address to my phone?

    1. Yes, sure. First tap on the settings icon beside the Wi-Fi network name. Once the pop-up opens, you will see IP settings at the bottom of the menu. The default option is “DHCP”. Tap on it to change the IP configuration.

  2. It would be nice that manuals for native ipv6 are written. Basically they are the same, however if you add a static IP(v6) in netplan or dhcpcd ther is always a hardware address added. That address is the default source address for outgoing connections.

    So far only native networking with interfaces is working correct.

    1. Thanks for your comment, we will inform you that in future posts, how to Set IPv6 on Ubuntu 20.04 LTS Server with netplan will be written. Please follow our articles.

Leave a Reply

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

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day