In this page we are discussing about how to set static ip in ubuntu 18.04.

At first we want to know how many network interfaces are available in our server, for this execute the command .

ifconfig -a

Then the output like:

To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant netplan network configuration file within /etc/netplan/ directory.Then you can see the file 01-netcfg.yaml or 50-cloud-init.yaml  .

Open the file using vi or other editers.

vi /etc/netplan/50-cloud-init.yaml

Then to set your network interface enp0s8 to static IP address give ip address ,gateway and dns servers.

Once all are done ,then execute the command:

sudo netplan apply

In case you run into some issues execute:

sudo netplan --debug apply

Now you set static ip to your server. You can confirm it by executing the command ipconfig -a.