Ubuntu 101: Static IP Address


First of all we check how our ip address "situation" is with one of these two commands:

ip a

or 

ip addr



As showed above in the screenshoot, I only have the network interface called enp0s4 without an IP address. So I am going to assign an IP static to this network interface. 

Before we go on with this procedure I will recommend you to backtup your file "netplan" (is where the configurations are written in yml format in Ubuntu). 

(This commands are valid for Ubuntu 20.4)

sudo nano /etc/netplan/01-netcfg.yaml


Did you notice any error below? 

Yes there is error, it can be tricky but the name of the interface by default is the wrong one in this case. 
As I do not have the interface enp0s5 I have the enp0s4 so this must be changed. 

Ctrl+C  and then Ctrl+X (Y and Enter)

Now we confirm the new configuration on the netplan with this command:

sudo netplan apply

After that we can analyze how all the operations went regarding the new configuration of the netplan with this command:

sudo netplan --debug apply



In case the interface is down you can use also the below command to correct that. 
ip link set up (name of the interface)





Comments

Leave as a comment:

Archive