Ubuntu Networking

The programs for configuring networking on Ubuntu are ifup and ifdown. The read their configuration from /etc/network/interfaces. See the man page for interfaces. Also, see /usr/share/doc/ifupdown/examples directory.

Setting auto for an interface means that it will be brought up either on network start or ifup -a.

Lines beginning with the word “auto” are used to identify the physical interfaces to be brought up when ifup is run with the -a option.

To make a device even recognized, all that needs to be done is set it to load automatically. This configuration will make the devices available, but not set anything for them:

auto eth0
iface eth0 inet manual

auto eth1
iface eth1 inet manual
Reload Network Configuration

To use new settings in your interfaces file, such as a new static IP address, bring the interface down, and back up.

ifdown eth0; ifup eth0

DHCP Client

In the simplest case, getting an address from a DHCP server is easy.

Here's an example:

auth eth0
iface eth0 auto dhcp

Additional options for the dhcp method:

Manual IP Configuration

Use a manual IP when you want the device to be available, but with no instructions attached to it.

Static IP Address

When setting a static IP address, use static as the inet type. Here's the other available options:

Here's an example of setting a static IP and manually setting DNS servers to Comcast:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address 192.168.1.2
	netmask 255.255.255.0
	gateway 192.168.1.1
	dns-nameservers 75.75.75.75 75.75.76.76

Google also offers some public DNS servers:

	dns-nameservers 8.8.4.4 8.8.8.8

Bonding

Documentation for bonding in Ubuntu is found in the ifenslave documentation – see /usr/share/doc/ifenslave.

In this scenario, active-backup bonding is set up, meaning that if the first device specified goes down, the second becomes the active device. The MAC address of the first device will continue to be used.

Before anything, the bonding module for the kernel has to be loaded. Once it is, you will have an ethernet device bond0 appear. Also install the ifenslave package.

modprobe bonding

Set up the system to load the bonding module on boot, in /etc/modules:

bonding

You will also need the ifenslave package installed:

apt-get install ifenslave

In /etc/network/interfaces, add the configuration for the Ethernet devices that will act as slaves:

auto eth0
iface eth0 inet manual
     bond-master bond0

auto eth1
iface eth1 inet manual
     bond-master bond0

Once they are added, add the settings for the bonding configuration. In this scenario, the connection is checked very 100 ms. The mode is active-backup, meaning that if one slave fails, the other will take over.

After that, you can configure the device as usual. For simplicity's sake, we're using DHCP here:

auto bond0
iface bond0 inet dhcp
     bond-primary eth0 eth1
     bond-mode active-backup
     bond-miimon 100

Load the new networking configuration. To be safe, bring the eth* devices down first:

ifconfig eth0 down
ifconfig eth1 down
ifup bond0