Network Configuration under Debian

From Thomas-Krenn-Wiki
Jump to: navigation, search

The article will provide an overview of how network configuration can be stored and modified in the /etc/network/interfaces configuration file under Debian.

Automated Activation during Booting

So that certain interfaces will be automatically activated during the boot process, they must be entered into the configuration file with the auto parameter.[1] The following example shows a system with a eth0 network card (the lo loopback interface should also always be enabled).

auto lo eth0

Configuring the Individual Interfaces

The following examples will show different potential configurations for the network interfaces.

Configuring the Loopback Interface

The loopback interface should always be present and will also be entered automatically.

iface lo inet loopback

Configuring a Static IP Address

A static IP address will be configured using iface eth0 inet static.[2] The following example demonstrates how to configure an IP address, a subnet mask, a default gateway and a DNS server.

iface eth0 inet static 
        address 192.168.0.111 
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-search somedomain.org
        dns-nameservers 192.168.0.1

Configuring a Dynamic IP Address (DHCP)

A dynamic IP address will be configured using iface eth0 inet dhcp.[3]

iface eth0 inet dhcp

Example of a System with Two Network Cards

The following example shows the configuration file for a system with two network cards. The first network card, eth0, automatically receives an IP address from DHCP (a default gateway will also be configured at the same time by DHCP). The second network card, eth1, will be configured with a static IP address.

debian:~# cat /etc/network/interfaces 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo eth1
iface lo inet loopback

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

iface eth1 inet static
	address 192.168.56.2
	netmask 255.255.255.0
debian:~# 

References

  1. Debian Reference (version 1) (Section 10.8.1 Changing Network Configurations while Booting)
  2. Debian Reference (version 1) (Section 10.6.1.1 Configuring an Interface with a Static IP Address)
  3. Debian Reference (version 1) (Section 10.6.1.2 Configuring an Interface using DHCP

Additional Information

Related articles

Hard Disk Formatting/Partitioning and Mounting in Debian Linux
Perl warning Setting locale failed in Debian
Setup FTP Server under Debian