Network Configuration in Debian 10

If you are a regular Linux user or system administrator, you may need to set up a network on your system. Unlike desktop systems, where you can use dynamic configurations, you will have to perform certain configurations on the servers depending on your network environment. Dynamic configurations constantly change after a server reboot, so in some cases it becomes necessary to have static configurations, for example, when remote server administration is required or when an application or service is running on the server that requires constant access. So, in this article we will explain how you can configure the core network in Debian based Linux. The basic configuration includes setting up a static IP, gateway, DNS, and host name.

We used the Debian 10 OS to describe the procedure mentioned in this article.

View current network configuration

To view the current network configurations, run the following command in Terminal. It will show the output for each interface in a separate section.

$ ip a

You can also run the ifconfig command to view the IP address.

$ ifconfig

Show network configuration using ifconfig command

Run the command below in Terminal to find the IP address of the DNS server:

$ cat /etc/resolv.conf

Change network configuration

The basic network configuration includes setting a static or dynamic IP address, adding a gateway, DNS server information. There are different ways to set up a network in Debian.

Method 1. Use the ifconfig and route command

In this method, we will see how to configure network settings. However, remember that these settings will not be permanent. After rebooting the system, the settings will be deleted.

1. Assign an IP address to the interface

We will use ifconfig to assign an IP address to our network interface. The following is the syntax of the command:

$ sudo ifconfig   netmask  up

In the following example, the command assigns the IP address to the eth0 network interface. The netmask is 24 ( bits.

$ sudo ifconfig eth0 netmask up

Assign IP Address

2. Set the default gateway

The default gateway is the address used to communicate with the external network. To configure the default gateway, use the following command syntax:

$ sudo route add default gw  

In the following example, I use as the address of my default gateway.

$ sudo route add default gw eth0

Set default gateway

3. Configure your DNS server

The DNS server resolves the domain name into an IP address so that the browser can download Internet resources. To configure the DNS name server address, use the following command syntax:

$ echo “nameserver ” > /etc/resolv.conf

In the following example, I set Google’s public DNS IP address as the address of my name servers, which is

$ echo “nameserver” > /etc/resolv.conf

Install DNS Servers

After that, you can verify your configuration by running the ifconfig command as follows: View changed network settings

Remove IP Address from Network Interface

To remove the IP address from the network interface, run the following command in the Terminal:

$ ip address del  dev 

Method 2: change network settings using the interfaces file

In this method, we will configure permanent network settings that your system will remember even after a reboot. To do this, we will have to edit / etc. / network / interfaces file using any text editor. To do this, execute the following command in the terminal:

$ sudo nano /etc/network/interfaces

Then add the following lines to it:

auto eth0

iface eth0 inet static




Now click Ctrl + O and then Ctrl + X save and exit the file.

Add Static IP

Please note that the address, netmask and gateway line must begin with a space! In case you want to dynamically assign an address, use the following lines:

auto eth0
iface eth0 inet dhcp

Definition (DNS) of name servers

To add information about the DNS server, we need to edit /etc/resolv.conf file. To do this, run the following command:

$ nano /etc/resolv.conf

I am adding two name servers here. One of them is the address of Google’s public DNS server, and the other is the IP address of my router.


Now click Ctrl + O and then Ctrl + X save and exit the file.

Install the name server in resolv.conf file

After that, you can check the IP address using ip a or Ifconfig command.

Check the modified config using the ip command

Method 3: change the network configuration through the Debian GUI

In this method, we will use the graphical way to configure the main network parameters.

To do this, press the Windows button on the keyboard, then in the search bar enter settings, From the results that appear, open settings. Then in the left sidebar, click on network Tab. After that, click on the gear icon of the interface you want to configure.

Debian Network Manager

Go to IPv4 Tab. to choose Guide and enter the IP address, netmask, gateway and DNS.

IPv4 Tab

If you want to dynamically assign an IP address, select the Automatically (DHCP) option and enter the DNS information.


After that click on Apply save changes.

Hostname setting

Like the IP address, a unique host name is also used to recognize the system on the network. To find the current hostname of your system, run the following command in Terminal:

$ hostname

Set host name

To change the host name of the system, you can run the following command. But as soon as you reboot the system, your original hostname will be restored.

$ hostname host_name

Here I change the hostname from Debian to Debian10.

Set a new host name

To permanently change the host name, you will need to edit the host name file located at / Etc. / hostnameEnter the command below to do this:

$ sudo nano /etc/hostname

Change hostname file

This file contains only the host name of the file, change the old name to the desired name and click Ctrl + O and Ctrl + X save and exit.

Some other useful commands you might need when setting up your network on Debian OS:


It can be used to test the connection between two systems in a local or global network. To check the connection to the device, enter ping and then the IP address or host name of this device:

$ ping 


Arp is used to translate IP addresses to Ethernet addresses. To print the arp table, type:

$ arp –a


It is used to display the routing table of a Linux system.

$ route


It translates host names into IP addresses and vice versa.

To find the IP for the specified domain:

$ host domain_name

Find the domain name at the specified IP address.

$ host IP_address

Enable and disable interface

To enable the interface, use:

$ ifup 

To disable the interface, use:

$ ifdown 

That is all there is to it! In this article, we explained how to set up a core network in Debian. We discussed various methods, including graphical and command line. You can choose the one that you find more simple and convenient.

Network Configuration in Debian 10