This is an old revision of the document!


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:

  • hostname - hostname to be requested
  • metric - metric for added routes (when using dhclient)
  • leasehours - request lease time in hours (when using pump)
  • leasetime - require least time in seconds (when using dhcpcd)
  • vendor - vendor class identifier (dhcpcd)
  • client - client identifier (when using dhcpcd or udhcpc)
  • hwaddress - MAC address

Manual IP Configuration

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

  • hwaddress <hwaddress> - link local address
  • mtu <size> - MTU size

Static IP Address

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

  • address - static IP address (required)
  • netmask - dotted quad or CIPR format
  • broadcast <address>
  • metric - routing metric for default gateway (type integer)
  • gateway - default gateway, dotted-quad format
  • pointtopoint - address of other end-point, dotted-quad format
  • hwaddress - MAC address
  • mtu - MTU size
  • scope - Address validity scope. Possible values: global, link, host

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 bond0 first, using the same setup as you normally would for an ethernet device (dhcp, static ip, etc.). After that, include a directive for bond-primary with the slave devices.

For the sake of simplicity, bond0 is getting an address assigned via DHCP.

It's important that the configuration for bond0 is first, since ifup and ifdown read them in order from first to last.

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

Add the slave devices, and set them as manually configured:

auto eth0
iface eth0 inet manual
     bond-master bond0

auto eth1
iface eth1 inet manual
     bond-master bond0

Load the new networking configuration:

ifup bond0