Ubuntu 18.04 LTS has a new method to configure static ip addresses. Unlike the previous versions, the Ubuntu 18.04 uses Netplan, a new command line network configuration utility, to configure IP address. Netplan enables easily configuring networking on a system via YAML files.

The default configuration files of Netplan are found under /etc/netplan/ directory. In this tutorial, we are going to learn how to configure static in Ubuntu 18.04 LTS server.
Configure Static IP Addresses on Ubuntu 18.04
To configure a static IP addresses on your Ubuntu 18.04 server you need to modify a relevant netplan network configuration file within /etc/netplan/ directory. For instance you might find there a default netplan configuration file called 01-netcfg.yaml or 50-cloud-init.yaml.
To do so, Edit following file.
sudo nano /etc/netplan/01-netcfg.yaml
Add below content to file with your address, gateway and dns details:
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no dhcp6: no addresses: [192.168.56.201/24] gateway4: 192.168.56.1 nameservers: addresses: [8.8.8.8,8.8.4.4]
As you can see, I already added my ip address. like that, you have to add your own server ip address. After that, Save the file and apply the new settings to networkd by executing command:
sudo netplan apply
Now your server is updated with new IP address. You can check current IP address by executing following command :
sudo ifconfig
sudo ip addr show
Finally, you can see that static IP address is configure to your server.
Leave a Reply