Linux Server Install: Part 5
Don’t be shocked with this one and setup a Static IP, bruh.
Previous
Static IP
To set up a static IP address on an Ubuntu 20.04 server and reserve it in the DHCP scope, follow these steps:
Determine the name of your network interface. You can use the ip
command to list your network interfaces:
ip a
The interface you want to configure will typically be called eth0
(for a wired Ethernet connection) or wlan0
(for a wireless connection).
Let’s assume your IP address is: 192.168.0.165/24
Edit the /etc/network/interfaces
file to configure the static IP address:
- Change
dhcp4
to no (it was yes) - On the
addresses
list specify the IP address that you want it to be: i.e.,192.168.0.222/24
- Next set the gateway, which is the gateway for the subnet (should be fine as is).
- Then in
nameservers
underaddresses
is another list. This is our nameserver list or “dns list”. For this we’ll use192.168.0.4
- Save this file and we’ll close out.
Apply the settings:
sudo netplan apply
You might be thinking that didn’t work, well that’s because we just got disconnected from our SSH session since we have a new IP address. SSH again using the new IP and you should be able to get back in.
Run ip a
again and you should see your new IP address.