Network Configuration

Network Configuration

By default, Debian is configured to connect to any available network via DHCP. If this is all you need, feel free to skip this section. If however, you’d like your host to have a static IP address, run through the following steps.

Update Configuration File

Open the interfaces file located under /etc/network.

sudo vim /etc/network/interfaces

Below is a default interfaces file with a single network interface.

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

To move to using a static IP address, update the last line to end in static, as follows:

# The primary network interface
allow-hotplug eth0
iface eth0 inet static

Next, add in the following lines which will define your static IP address.

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 10.1.0.50
netmask 255.255.255.0
gateway 10.1.0.1
dns-domain ad.twobyte.blog # Optional
dns-search ad.twobyte.blog # Optional
dns-nameserver 10.1.0.20 10.1.0.21

Reload Network Service

Lastly, to have your configuration take effect, restart the networking service.

sudo systemctl restart networking

Verify Configuration

To confirm and verify the network configuration, run ip addr.

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 02:35:5d:bd:34:0d brd ff:ff:ff:ff:ff:ff
    inet 10.1.0.50/24 brd 10.1.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fea6:480e/64 scope link
       valid_lft forever preferred_lft forever

To check your DNS configuration cat the contents of your /etc/resolv.conf file.

cat /etc/resolv.conf

# Output:

domain ad.twobyte.blog
search ad.twobyte.blog
nameserver 10.1.0.20
nameserver 10.1.0.21