×


Configure Static IP Addresses on Ubuntu 18.04 Server - Step by Step Process ?

Ubuntu 18.04 LTS has an easy 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.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Linux System IP queries.

In this context, you shall learn how to configure static in Ubuntu 18.04 LTS server.


How to Configure Static IP Addresses on Ubuntu ?

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]

Here, we added an 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.


[Need urgent assistance in setting up Static IP addresses on your Linux System? We can help you. ]


Conclusion

This article covers method to set up a static IP address on Ubuntu 20.04. Basically, in most network configurations, the IP address is assigned dynamically by the router DHCP server. 

The recommended way to assign a static IP address to a device on your LAN is to configure a Static DHCP on your router. Static DHCP or DHCP reservation is a feature found on most routers which makes the DHCP server to automatically assign the same IP address to a specific network device, each time the device requests an address from the DHCP server. This works by assigning a static IP to the device's unique MAC address.


To Get the name of network interface and the default gateway in Linux:

You can either use ip command or the network manager CLI like this:

$ nmcli d