Home | Networks & The Internet | All About Computers | Our Warped Views | Downloads | Forums
7th January, 2009
Contact Us | Usage Agreement

Basic Networking And LAN's


 

Manually Configure Ubuntu (7.10) IP Addresses

Updated: 8th January 2008

 

I use a couple of Ubuntu machines as test boxes. As a result I’m constantly changing the settings to place them on parts of the network I need them to be, and have noticed (as with Debian) that after a few disconnects and reconnects – Ubuntu starts to loose the plot.

Fortunately you can still do it the manual way. This quick guide explains how to change the IP addresses for any interface on your Ubuntu Linux box. It also applies to Debian.

You’ll need root access to the machine, follow these steps:

Start with opening a terminal shell:

Applications -> Accessories -> Terminal

Alternatively, you can move to one of the free TTY sessions using the ALT-F1 to ALT-F6 keys and login.

Type ‘sudo /etc/init.d/networking stop’ to disable the current interfaces. You may be prompted to enter your root password or suoders password.

Next, type ‘sudo nano /etc/network/interfaces’ to open the interfaces file for editing.

You should see the following:

The ‘interfaces’ file contains information about your IP setup for each adapter on your PC. Since mine is a laptop with wireless disabled, it only has two interfaces:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

The two interfaces are ‘lo’ and ‘eth0’. ‘lo’ is present on all systems and simply means the ‘loopback’ interface. It’s a means of testing the IP stack, or for applications that need to communicate locally using IP. The interface we are interested in is the ‘eth0’ adapter – the local Ethernet adapter.

Note:

The ‘auto’ keyword in front of each adapter specifies that the system should attempt to load this device on start-up. If you want to remove a networking device from the system configuration and speed up the boot time, this is one way of doing it. Though don’t remove the ‘lo’ device!

In order to specify a static IP address for our Ethernet connection, we need to change one line and add a few others. Simply change the line:

iface eth0 inet dhcp

To:

iface eth0 inet static

Then, we need to add the actual values for the IP address, subnet mask, and default gateway. Directly below the last line, add the following:

address x.x.x.x
netmask x.x.x.x
gateway x.x.x.x

Replace the values with the real IP address, subnet mask and default gateway of your network.

You then need to save the file by hitting CTRL-O and Enter, and then finally exit ‘nano’ using CTRL-X.

Once the settings are saved, it’s time to bring the network back up. Issue the following command:

sudo /etc/init.d/networking start

If all goes well, the network will come online and the interface will be ready to use. The following screenshot is what you should expect to see:

However, if there is an error in the interfaces file, you'll get a message point it out. For example, the following screenshow shows an error found in the 'netmask' value, an incorrect value of 255.255.255.251 has been entered:

Simply repeat the steps above to correct the error or check your spelling in the file, and try activating the card again. Note that the cable does not need to be physically connected for Linux to enable the interface.

© 2007 John Payne, The-serpent.co.uk