Brainstorm's snippets (1/275)

  Network Configuration in Debian 10

Preliminary downloads

Create the following VMs:

  • debian1 (root/debian1, master/debian1)
  • debian2 (root/debian2, master/debian2)

How to Install VirtualBox Guest Additions on Debian 10 Linux:

Additional settings:

apt install net-tools
apt install sudo

echo 'export PATH=/usr/sbin:$PATH' >> ~/.bashrc

View current network configuration

$ ip a


$ ifconfig

To find out the DNS servers IPs:

$ cat /etc/resolv.conf

Change network configuration (temporary)

Basic network configuration includes setting:

  • a static or dynamic IP address
  • adding a gateway
  • adding DNS server information

The following commands will change network settings; however, the new settings will not be permanent: once you reboot your system, the settings will be removed.

1. Assign an IP address to the interface

sudo ifconfig <interface> <IP_address> netmask <subnetmask> up


sudo ifconfig eth0 netmask up

2. Set the Default Gateway

sudo route add default gw <IP_address> <interface>


sudo route add default gw eth0

3. Set Your DNS server

echo "nameserver <IP_address>" > /etc/resolv.conf


echo "nameserver" > /etc/resolv.conf

4. Remove IP address from a network interface

ip address del <IP_address> dev <interface>

Once done, you can test your configuration by running the ifconfig command as follows:

sudo ifconfig -a

Change network settings permanently by using the interfaces file

Add a static address (file `/etc/network/interfaces`):

auto eth0

# static IP address
iface eth0 inet static

Please note that the address, netmask and gateway line must start with leading whitespace!

Dynamically assign the address (file `/etc/network/interfaces`):

auto eth0
iface eth0 inet dhcp

Defining the (DNS) Nameservers

To add DNS server information, we will need to edit the /etc/resolv.conf file.



Reload network settings

ifdown eth0
ifup eth0

Configurazione DHCP server

sudo apt-get update
sudo apt-get install isc-dhcp-server

cat /etc/default/isc-dhcp-server


cat /etc/dhcp/dhcpd.conf

    default-lease-time 600;
    max-lease-time 7200;

    subnet netmask {
        option routers;
        option domain-name-servers;
        option domain-name "";

        #host TOR-datacenterclient {
        #    hardware ethernet 08:00:27:27:3a:1c;
        #    fixed-address;


systemctl stop isc-dhcp-server
systemctl start isc-dhcp-server

tail -f /var/log/syslog

Comandi utili

ip addr
route -n
ip route