The first thing you must do is locate the name of your network device. For that, issue the command:
ip -c link show
You should at least see two devices, lo (for loopback) and another named device (such as enp0s3).
Next, let’s back up the current network configuration file with the command:
sudo cp /etc/network/interfaces ~/
Open the configuration file for editing with the command:
sudo nano /etc/network/interfaces
If you find nano isn’t installed, add it with the command:
sudo apt-get install nano -y
With the interfaces file open for editing, you should see a DHCP configuration that looks like this:
# The primary network interface
allow-hotplug enp0s3
iface enp0s3 inet dhcp
Comment that block out so it looks like this:
# The primary network interface
# allow-hotplug enp0s3
# iface enp0s3 inet dhcp
Now, we can add the necessary configuration for a static IP address. Let’s configure enp0s3 to use the address 192.168.1.97, with a gateway of 192.168.1.1, and a DNS nameserver of 1.1.1.1. That configuration will look like this:
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.97
netmask 255.255.255.0
gateway 192.168.1.1
dns-domain example.com
dns-nameservers 1.1.1.1
Make sure to edit the above configuration to match your network scheme. Save and close the file.
Finally, restart the networking service with the command:
sudo systemctl restart networking
Make sure the networking configuration is correct, by issuing the command:
ip a