Printed from http://kimbriggs.com

Static (Fixed) IP Address in Debian & Ubuntu Linux

Background

This page shows how to set up static IP addresses for a personal computer on a home network using both a GUI interface and the direct method of editing the appropriate configuration files. This is important in my home network for using NFS Linux-to-Linux file sharing and for using Virtual Hosts in a private LAN development environment.

I'm also posting a special note which I hope will be outdated soon: As of 2009-12, using the GUI method in Debian 5.03 (Lenny), does not work. A static IP address does not "stick" and every time the computer is rebooted, it reverts to DHCP. See the section below on manually editing the configuration file.

Debian & Ubuntu Gnome Networking GUI

The default desktop environment for Debian and Ubuntu Linux is Gnome, and these Graphical User Interface (GUI) notes refer only to the Gnome desktop. To administer the networking settings, go to System --> Administration --> Network. You will see a window like the one below.

Networking Dialog

You may see multiple entries where I only have one. Click on the network card that you want to give a fixed IP to and then click on the "Properties" tag. Most likely, the "Enable Roaming Mode" box will be selected and all the boxes below will be blank. To enable a static IP, DESELECT the "Roaming Mode" box, choose "Static IP Address" from the Configuration drop-down box, and fill in the boxes.

NIC Card Dialog

Starting from the bottom, it is common for a home network router (switch) have the value of 192.168.1.1. This is your Gateway Address. If yours does have this value, then your static IP will have the form of "192.168.1.x", where x is random number between 2 and 254. For some binary reason, the Subnet Mask is always 255.255.255.0 in the home network setups.

Manually Editing the Configuration File

I found out that the file you need to edit to set networking interfaces is, surprisingly enough,  /etc/networking/interfaces . Below is a *section* of the file that deals with your first Ethernet card only (eth0). I don't understand why everything is there, so use at your own risk. I left extra information in from the file I copied it from. The "#" mark is a comment symbol and my system worked without entering these extra values. If you wanted to try this, you would edit the section for eth0 and not add an additional entry.

NOTE: You need to edit this file with "superuser" priveledges. If you are the only use in Ubuntu, then you qualify. In Debian, you can use the "su" command to become root. In Ubuntu you would use "sudo" followed by your editor command. Edit the file in a terminal using "nano", or even use "gedit" since this is a desktop home network.

auto eth0
iface eth0 inet static
address 192.168.1.21
netmask 255.255.255.0
#network x.x.x.x
#broadcast x.x.x.x
gateway 192.168.1.1

Restart of Networking Service is Required

You would need to restart the networking service (superuser again) no matter which method you used to change the network interface. You can always reboot your computer to make sure that networking is restarted, or you can issue the command below in a terminal (Apps --> Accessories --> Terminal).

me@myhost$ sudo /etc/init.d/networking restart

 
 
CC License Ubuntu Get OpenOffice Graphics by GIMP Bluefish Editor Eliminate DRM Get Firefox php.net Play Ogg what's this?
 
Custom Search