The majority of network setup can be done via the interfaces configuration file at /etc/network/interfaces. Here, we can give our network card an IP address (or use dhcp), set up routing information, configure IP masquerading, set default routes and much more.
Using DHCP to automatically configure the interface
auto eth0 allow-hotplug eth0 iface eth1 inet dhcp iface eth2 inet6 dhcp #For DHCPv6 (used for IPv6) iface eth3 inet6 auto #stateless address autoconfiguration, or SLAAC
Configuring the interface manually
auto eth0 iface eth0 inet static address 192.168.12.20 netmask 255.255.255.0 gateway 192.168.12.1 auto eth1 iface eth1 inet6 static address 2001:db8::c0ca:1eaf netmask 64 gateway 2001:db8::1ead:ed:beef
Add DNS nameserver
Setting the speed and duplex
auto eth0 iface eth0 inet static address ... netmask ... gateway ... up sleep 5; ethtool -s eth0 ...
Bringing up an interface without an IP address
iface eth0 inet manual pre-up ifconfig $IFACE up post-down ifconfig $IFACE down
iface eth0.99 inet manual post-up ifconfig $IFACE up pre-down ifconfig $IFACE down
auto interface – Start the interface(s) at boot. That’s why the
lo interface uses this kind of linking configuration.
allow-auto interface – Same as
allow-hotplug interface – Start the interface when a “hotplug” event is detected. In the real world, this is used in the same situations as
auto but the difference is that it will wait for an event like “being detected by udev hotplug api” or “cable linked”.
inet static – Defines a static IP address.
inet manual – Does not define an IP address for an interface. Generally used by interfaces that are bridge or aggregation members, or have a VLAN device configured on them.
inet dhcp – Acquire IP address through DHCP protocol.
inet6 static – Defines a static IPv6 address.
address – IP address for a static IP configured interface
netmask – netmask
gateway – The default gateway of a server. Be careful to use only one of this guy.
down – Use the following command to down the interface instead of
post-down – Actions taken right after the interface is down.
pre-up – Actions before the interface is up.
up – Use the following command to up the interface instead of
Refer https://wiki.debian.org/NetworkConfiguration for more configuration options.