Search This Blog

2011-02-23

DNS, DHCP and Static IP with Ubuntu

I finished setting up an Ubuntu server a test lab, and quickly learned a few tips for DHCP and static IP addresses.

Setting and Interface for DHCP

If you want to change an interface to use DHCP, edit /etc/network/interfaces making sure you remove the static config

Example:
nano /etc/network/interfaces

iface eth0 inet static
address 192.168.0.x
netmask 255.255.255.0
network 192.168.0.x
broadcast 192.168.0.255
gateway 192.168.0.x

to

iface eth0 inet dhcp

The reverse can be done to change from DHCP to static.

Adding Alternative DNS server

Since DNS servers are handled by the DHCP, I wanted to add an alternative DNS server. Editting the dhclient.conf lets you do this and adding the following the lines to the file.

Example:
nano /etc/dhcp3/dhclient.conf

prepend domain-name-servers 127.0.0.1

or use supersede to replace them.

supersede domain-name-servers 127.0.0.1

Now the your Ubuntu server can run with DHCP with alternative DNS servers.

Use /etc/init.d/networking restart to apply the changes for the DHCP and DNS right away.

No comments:

Post a Comment