Configuring DHCP Addressing for Ubuntu Linux
Normally the network interface cards are configured during the installation of Linux. However, sometimes certain circumstances require you to change the addressing scheme of your system. This article will take you step by step through the process of configuring your system to use DHCP for obtaining its IP addressing information. Ubuntu has some very nice GUI tools to allow you to change your settings with the click of the mouse but this article will focus on how to make your changes from a command line in the event that you don’t have the GUI installed. Also, this tutorial is Ubuntu/Debian centric but the principles can be applied to many other Linux distributions, especially any that are based on Debian.
There is one tool that is needed, a text editor. In this article we’ll use the nano editor. Nano is a nice and easy editor that is installed by default in Ubuntu.
(*note: Commands preceded by a “$” are run as a normal user and commands preceded by a “#” are run as root.)
All of the network interface settings are contained in a text file. In order to change any settings we just need to edit the file correctly and restart the networking services. The file we need to edit is stored in /etc/network/interfaces.
The first thing we need to do is login. You know the drill…
Username
Password
Success!
In order to make any system changes like network interface settings, we need to have root privileges. Use the “su” command to change to root.
$ su
And the root password is required.
Alright, before we get into editing any settings, I want to suggest that you make a backup of the file we are editing. We are editing the file stored in /etc/network/interfaces. I don’t have a screen shot of backing up the file because I was bad and didn’t do it. However, an easy way to back the file up would be as follows:
# cp /etc/network/interfaces /etc/network/interfaces.backup
That command will give us a copy of interfaces called interfaces.backup that we can restore if necessary.
Now we can open the interfaces file for editing. We will use the nano editor with the “-w” option to signify no wrapping of long lines of text.
# nano -w /etc/network/interfaces
Since we are changing the system to use DHCP we need to remove some of the information that pertains to static IP addressing. Notice below that there are several indented lines.
We need to remove this section of data:
address 192.168.200.10
netmask 255.255.255.0
network 192.168.200.0
broadcast 192.168.200.2
# dns-* options are implemented…
dns-nameservers 192.168.200.2
Notice here that the interface is set to static.
Remove the word “static”…
…and replace it with “dhcp”.
Were all done editing, press “ctrl-x” to close the file. Nano will respond by asking if you want to save.
Press “y” to save.
Nano will ask for a name and path to save the file.
Just press enter to save the modifications over the original file.
You know the save was successful when nano tells you that it wrote X lines. If you get a save error, you most likely aren’t root.
To make the new setting take effect, we need to restart the networking services. That is accomplished with the following command:
# /etc/init.d/networking restart
Notice that when the restart is initiated we see that it is using DHCP.
Let’s check to see if we received an IP address dynamically. Issue the command:
# ifconfig eth0
(*substitute eth0 with the interface appropriate to your system)
If we see address information like below, we know that it’s working.
We’re all finished with our network changes, let’s log out of root privilege mode.
# exit
Let’s log out of user mode as well.
$ exit























Stu Fisher said,
Wrote on December 8, 2007 @ 7:13 pm
I am having a problem similar to this on UBUNTU version 7.1 but the code in the file etc/network/interfaces is different as shown below:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
auto eth2
iface eth2 inet dhcp
auto ath0
iface ath0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
auto dsl-provider
iface dsl-provider inet ppp
provider dsl-provider
pre-up /sbin/ifconfig eth0 up # line maintained by pppoeconf
grand casino online said,
Wrote on February 12, 2008 @ 11:29 pm
grand casino online…
Banks denigrate.overly assignable devoted …
tips poker said,
Wrote on February 17, 2008 @ 10:55 am
tips poker…
spreaders multiplexes minces asks?habitats …
cancellation of debt said,
Wrote on February 20, 2008 @ 11:46 pm
cancellation of debt…
hobbling!pinto shifted.pronouns Nazareth.sight …
bingo online casino with sign up bonus said,
Wrote on February 24, 2008 @ 2:39 am
bingo online casino with sign up bonus…
wearied:intelligibly?wakes sources?…
bingo game show said,
Wrote on February 28, 2008 @ 6:08 pm
bingo game show…
firstly flowcharts cored.inglorious.sprinkling:crypt …
sécurité des jeux de hasard en ligne said,
Wrote on August 6, 2008 @ 6:00 pm
sécurité des jeux de hasard en ligne…
diffusers Madagascar threading allays …
pocker games online said,
Wrote on September 1, 2008 @ 9:42 pm
pocker games online…
specimen:understandably stirring Malagasy …
absolutely free health insurance said,
Wrote on October 4, 2008 @ 6:48 am
absolutely free health insurance…
net Confucianism thanks Corinth confluent …