Introduction
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.
Prerequisites
- 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.
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.
This file may look like the following.
Edit the configuration as follows.
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.
Conclusion
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.
NOTE :
# Wired adapter #1
allow-hotplug eth0
no-auto-down eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.113
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
# hwaddress ether # if you want to set MAC manually
# pre-up /sbin/ifconfig eth0 mtu 3838 # setting MTU for DHCP, static just: mtu 3838
# Wireless adapter #1
# Armbian ships with network-manager installed by default. To save you time
# and hassles consider using 'sudo nmtui' instead of configuring Wi-Fi settings
# manually. The below lines are only meant as an example how configuration could
# be done in an anachronistic way:
#
#allow-hotplug wlan0
#iface wlan0 inet dhcp
#address 192.168.0.100
#netmask 255.255.255.0
#gateway 192.168.0.1
#dns-nameservers 8.8.8.8 8.8.4.4
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
# Disable power saving on compatible chipsets (prevents SSH/connection dropouts over WiFi)
#wireless-mode Managed
#wireless-power off
# Local loopback
auto lo
iface lo inet loopback
https://www.snel.com/support/how-to-configure-static-ip-on-debian-10/
Nhận xét
Đăng nhận xét