Steps How to Configure a Static IP Address on Ubuntu 20.04 Operating System

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Static IP Address. FOTO/Gmedia

It is a good idea to set a static or fixed ip address to a server so that you can guarantee that the machine will always have the same ip address to make it easier to connect to.

We prefer to set a static ip dynamically using my dhcp server but if you prefer to add a static IP address then this can easily be done using the following process:

ADVERTISEMENTS

Set a static IP address:

Find the correct interface name:

Open a terminal and run the following command:

ADVERTISEMENTS
ip a

 

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

ADVERTISEMENTS

In the example above the network card is eth0 as it is the only interface with an ip address.

ADVERTISEMENTS

Backup the networking file

It is a good idea to back up the networking file before you make any changes so that it can be quickly reverted if things go wrong. Run the following command to make a backup copy of the file:

ADVERTISEMENTS
sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak

This will create a file called 00-installer-config.yaml.bak in the /etc/netplan/ folder in case you need it.

ADVERTISEMENTS

Edit the 00-installer-config.yaml file to set the static IP Address

Edit the 00-installer-config.yaml file in your desired editor

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

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

If your server is set to dhcp then you will see something like:Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Edit the file to look something like:

Save the file.

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik fotoⒸ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

Apply the changes:

sudo netplan apply

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik fotoThe server will then be using the new address. If you were connected via ssh you will have to open a new session and connect to the NEW IP ADDRESS:

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

The server will now use this address every time it is rebooted from now on.

To revert the changes you just need to do the following:

Over write the edited file with the backup file:

sudo cp /etc/netplan/50-cloud-init.yaml.bak /etc/netplan/50-cloud-init.yaml

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik fotoReload netplan:

sudo netplan apply

Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik fotoThe server will now be configured for dhcp and should have its old ip address again:Ⓒ Hak cipta foto di atas dikembalikan sesungguhnya kepada pemilik foto

The server is now ready to install what ever software that you would like to install. For some ideas of what to install go to our Ubuntu Section of the site.

Exit mobile version