In a typical network, there are two ways to assign IP addresses. One is using DHCP and another is static IP assignment. DHCP or Dynamic Host Control Protocol dynamically assigns an IP address to an interface. It requires a DHCP server running in the network. In the static IP assignment, we manually assign the IP address, routing gateway, and DNS resolvers. Static IP assignment gives to more control on assigning an IP address and setting the DNS resolvers.
In this tutorial, we will learn how to assign static IP address on Debian 10 “Buster” server.
- Cloud VPS or Dedicated Server with Debian 10 installed.
- You must be logged in via SSH as a sudo or root user.
Step 1: Log in to shell using SSH
If you are not already logged into your remote server, login via SSH by following this guide.
Step 2: Find Network Interfaces
Run the following command to get the active network interfaces.
ip link show
As we can see in the above screenshot, lo is the loopback interface which is an internal virtual interface used by the computer to communicate with itself.
The second interface ens18 is the active Ethernet adapter, which our server is using to connect to the internet. Now that we have found the adapter interface, we will assign the static IP on this interface. In your case, the adapter name can be different.
Step 3: Find the IP address assigned to the Interface
If you are a Snel user, you can go to the VPS dashboard and navigate to Network >> Interfaces.
Under interfaces, you will find the IP address assigned to the adapter.
Note that the example IP address is shown near 1, which is 192.168.0.2. The subnet mask will be 255.255.255.0 and Gateway will be 192.168.0.1. DNS resolver servers are marked at 2 and 3. In your actual case, these addresses will be different.
If you are unsure about these values, please feel free to contact Snel Support.
Step 4: Assign Static IP Address
Edit the network configuration file by running the following command.
sudo nano /etc/network/interfaces
This file may look like the following.
Edit the configuration as follows.
auto ens18 iface ens18 inet static address 192.168.0.2 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 184.108.40.206 220.127.116.11
Make sure not to change the loopback adapter config. After the change, it will look something like the following screenshot.
Save the file and exit from the editor.
Step 5: Restart Networking Service
Restart the networking service so that the updated configuration can be applied. Run the command.
sudo systemctl restart networking
In this tutorial, we have learned how to configure a static IP address on Debian 10 “Buster” server. Your server is now configured to use static IP address.