Networking - Ubuntu 7.x

 

Networking - Ubuntu 7.x

 

+

Search Tips   |   Advanced Search

 

Overview

Ubuntu ships with a number of graphical utilities to configure your network devices. This document is geared toward server administrators and will focus on managing your network on the command line.

 

Ethernet

Most ethernet configuration is centralized in a single file...

/etc/network/interfaces

If you have no ethernet devices, only the loopback interface will appear in this file, and it will look something like this:

### loopback network interface
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

If you have only one ethernet device, eth0, and it gets its configuration from a DHCP server, and it should come up automatically at boot, only two additional lines are required:

auto eth0
iface eth0 inet dhcp

The first line specifies that the eth0 device should come up automatically when you boot. The second line means that interface eth0 should have an IPv4 address space and that it should get its configuration automatically from DHCP.

Assuming your network and DHCP server are properly configured, this machine's network should need no further configuration to operate properly. The DHCP server will provide the default gateway (see route command), the device's IP address (see ifconfig command), and DNS servers used on the network. implemented in...

/etc/resolv.conf

To configure your ethernet device with a static IP address and custom configuration, some more information will be required. Suppose you want to assign the IP address...

192.168.0.2

...to the device eth1, with the typical netmask of...

255.255.255.0

Your default gateway's IP address is...

192.168.0.1

Edit...

/etc/network/interfaces

...and enter something like this...

iface eth1 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1

In this case, you will need to specify your DNS servers manually...

/etc/resolv.conf

...which should look something like this:

search setgetweb.com
nameserver 192.168.0.1
nameserver 4.2.2.2

The search directive will append setgetweb.com to hostname queries in an attempt to resolve names to your network. For example, if your network's domain is...

setgetweb.com

...and you try to ping the host "ubuntu", the DNS query will be modified to...

ubuntu.setgetweb.com

...for resolution. The nameserver directives specifiy DNS servers to be used to resolve hostnames to IP addresses. If you use your own nameserver, enter it here. Otherwise, ask your Internet Service Provider for the primary and secondary DNS servers to use, and enter them into...

/etc/resolv.conf

Many more configurations are possible, including dialup PPP interfaces, IPv6 networking, VPN devices, etc. Refer to man 5 interfaces for more information and supported options. Remember that...

/etc/network/interfaces

...is used by the ifup and ifdown scripts as a higher level configuration scheme than may be used in some other Linux distributions, and that the traditional, lower level utilities such as ifconfig, route, and dhclient are still available to you for ad hoc configurations.

 

Managing DNS Entries

This section explains how to configure which nameserver to use when resolving IP addresses to hostnames and vice versa. It does not explain how to configure the system as a name server.

To manage DNS entries, you can add, edit, or remove DNS names from...

/etc/resolv.conf

A sample file is given below:

search com
nameserver 204.11.126.131
nameserver 64.125.134.133
nameserver 64.125.134.132
nameserver 208.185.179.218

The search key specifies the string which will be appended to an incomplete hostname. Here, we have configured it to com. So, when we run: ping ubuntu it would be interpreted as ping ubuntu.com.

The nameserver key specifies the nameserver IP address. It will be used to resolve a given IP address or hostname. This file can have multiple nameserver entries. The nameservers will be used by the network query in the same order.

If the DNS server names are retrieved dynamically from DHCP or PPPoE (retrieved from your ISP), do not add nameserver entries in this file. It will be overwritten.

The changes you made...

/etc/resolv.conf

...will be erased when you reboot your machine. To make this change permanent, install the resolvconf package from the Universe repository and update the DNS information in...

/etc/resolvconf/resolv.conf.d/base

...provided by that package.

 

Managing Hosts

To manage hosts, you can add, edit, or remove hosts from...

/etc/hosts

The file contains IP addresses and their corresponding hostnames. When your system tries to resolve a hostname to an IP address or determine the hostname for an IP address, it refers to the /etc/hosts file before using the name servers. If the IP address is listed in the /etc/hosts file, the name servers are not used. This behavior can be modified by editing...

/etc/nsswitch.conf

If your network contains computers whose IP addresses are not listed in DNS, it is recommended that you add them to the /etc/hosts file.

 

  Home