Table of Contents

/etc/network/interfaces

The reference documents for this Debian configuration file are:

Examples

WiFi interfaces with WPA

See this two pages: wpa_supplicant in Debian 6.0 and How To Use wpasupplicant.

Automatic IP address and WPA security (credential can be in the same file, or in wpa_supplicant.conf:

allow-hotplug wlan0
iface wlan0 inet dhcp
    #wpa-ssid MyESSID
    #wpa-psk MyWPASecret
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Static IP address with WPA security; with this configuration the WiFi connection will be not managed by NetworkManager:

auto wlan0
iface wlan0 inet static
        address 10.0.0.166
        netmask 255.255.255.0
        gateway 10.0.0.189
        dns-nameservers 62.48.51.6 151.99.125.2
        #wpa-ssid MyESSID
        #wpa-psk MyWPASecret
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Static IP address, without encryption:

auto eth1
iface eth1 inet static
        address 192.168.0.191
        netmask 255.255.255.0
        gateway 192.168.0.249
        dns-nameservers 62.48.51.6 8.8.8.8
        wireless-essid MyESSID
        wireless-mode Managed
        wireless-key off

Static address, not managed by NetworkManager

Debian (9 Stretch) installs the network-manager package, which handles the configuration of Ethernet interface automatically, via DHCP. If you want to manually configure the interface, just put this in /etc/network/interfaces configuration file:

allow-hotplug enp2s0
iface enp2s0 inet static
        address 10.0.1.2
        netmask 255.255.255.0
        gateway 10.0.1.252
        dns-nameservers 144.76.67.15 8.8.8.8

You need the resolvconf package to make the dns-nameservers option working. That option adds the nameserver line into the /etc/resolv.conf file at boot time.