2. Configuring network interfaces

To configure network interfaces persistently, you have to edit the file /etc/network/interfaces. Network interfaces configured in this file can be brought up and down with the tools ifup and ifdown.

auto interfaceinterface should be brought up when using ifup -a, i.e. when booting the system
iface interface

configure interface

lines starting with #ignored as comments

Table 3.1. Elements of /etc/network/interfaces

The full syntax of the iface directive is:

iface interface address_family method
 option1 value1
 option2 value2

2.1. Automatic configuration (DHCP)

To use DHCP on eth0, you would enter the following into the configuration file.

auto eth0
iface eth0 inet dhcp

Example 3.1. DHCP network configuration

As this is the default, you normally do not have to do this.

2.2. Static configuration

In Example 3.2, “Static network configuration with all options” you can see a static configuration for eth0. The IP address is assigned and is used as the default gateway. The options network and broadcast are optional.

iface eth0 inet static

Example 3.2. Static network configuration with all options (network and broadcast are optional)