This tutorial will walk you through configuring your network setting for Debian 9 Stretch. I will show you how to set static address and dynamic address for IPv4 and IPv6.
GNOME Desktop
The default desktop environment for Debian 9 Stretch is GNOME 3. We will focus on this environment,
IPv4 Static Address
IPv4 DHCP
IPv6 Static Address
IPv6 DHCP
Terminal
For more advanced users and those running a GUI-less server, the following instructions will aid you.
All configuration can be found under /etc/network. You may either define all of your interfaces in a single file or place them in individual files under /etc/network/interfaces.d.
Understanding Network Interface Names
Most recent distributions have switched over to predictable naming. Prior to this an interfaces name was derived from the order it was discovered; the first interface would be named eth0, the second eth1, and so on. The problem with this approach is eth0 wasn’t always the same slot, making troubleshooting difficult.
I cover this topic in much more detail in Understanding Predictive Interface Naming in Linux. For most, the naming convention would be the following:
<interface type><bus number><slot number>
For example, an Ethernet interface – the most common – found on bus 0 and slot 3 of your motherboard would be named:
enp0s3
IPv4 Static Address
- Open the network interface configuration file into a text editor, such as VI.
- Add the following lines.
auto enp0s3 iface enp0s3 inet static address 192.168.1.20 netmask 255.255.255.0 gateway 192.167.1.1
- Save your changes and exit the text editor.
- Bring the interface down.
ifdown enp0s3
- Bring the interface back up.
ifup enp0s3
- Verify your network settings have been applied.
ip a
IPv4 DHCP
- Open the network interface configuration file into a text editor, such as VI.
- Add the following lines.
auto enp0s3 iface enp0s3 inet dhcp
- Save your changes and exit the text editor.
- Bring the interface down.
ifdown enp0s3
- Bring the interface back up.
ifup enp0s3
- Verify your network settings have been applied.
ip a
IPv6 Static Address
- Open the network interface configuration file into a text editor, such as VI.
- Add the following lines.
auto enp0s3 iface enp0s3 inet6 static address fd9f:2685:51fa:2e4e:xxxx:xxxx:xxxx:xxxx netmask 64 gateway fd9f:2685:51fa:2e4e:xxxx:xxxx:xxxx:xxxx
- Save your changes and exit the text editor.
- Bring the interface down.
ifdown enp0s3
- Bring the interface back up.
ifup enp0s3
- Verify your network settings have been applied.
ip a
IPv6 DHCP
- Open the network interface configuration file into a text editor, such as VI.
- Add the following lines.
auto enp0s3 iface enp0s3 inet6 auto
- Save your changes and exit the text editor.
- Bring the interface down.
ifdown enp0s3
- Bring the interface back up.
ifup enp0s3
- Verify your network settings have been applied.
ip a