Monday, July 20, 2009

How to install DHCP server on Ubuntu

Today I had to set up dhcp server on a machine running Ubuntu 9.04. The machine was supposed to serve 10 other machine running ubuntu/windows xp. Here is the steps I followed.

Install static IP on the machine. ( I selected 192.168.0.1 as the IP for the machine running dhcpd )

$ sudo apt-get install dhcp3-server

Now edit the /etc/dhcp3/dhcp3d.conf.
The default config file supplied with the dhcpd package is some what cumbersome. I replaced it with the following simple file


# dhcpd.conf config file.

authoritative;

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.20 192.168.0.250;
option domain-name "mynet.local";
option domain-name-servers 192.168.0.1;
option broadcast-address 192.168.0.255;
option routers 192.168.0.1;
# next-server 192.168.0.1;
# get-lease-hostnames true;
option subnet-mask 255.255.255.0;

}


Then I restarted the server .

$ sudo /etc/init.d/dhcp3-server restart

The above configuration file will serve IP range from 192.168.0.20 to 192.168.0.250. If you have a different IP scheme modify the values as required. In fact , there are several other options for dhcpd which you can control. The original config file has some examples settings explained in it.

If you have multiple interfaces on the machine, modify /etc/default/dhcp3-server file to specify which interface the server should run.


3 comments:

Anonymous said...

Hi, I like your blog. It's so simple and straightforward.

Can't wait to read all your articles.

But, I'm new to an Ubuntu server and I've a question, what if we already have a router in the office network?

I've tried turning off the DHCP on the router, but the computers that don't need to be "served" by the server can't have Internet access.

The reason I ask is if it's just 1 computer user on the weekends, do I really need to turn on the server just for Internet?

Thanks. =)

Anonymous said...

Hi, I like your blog. It's so simple and straightforward.

Can't wait to read all your articles on your blog.

But, I'm new to an Ubuntu server and I've a question, what if we already have a router in the office network?

I've tried turning off the DHCP on the router, but the computers that don't need to be "served" by the server can't have Internet access.

The reason I ask is if it's just 1 computer user on the weekends, do I really need to turn on the server just for Internet?

Thanks. =)

Fermi Level said...

@artpablico

The router is basically meant for routing packets. But modern gizmos that we call router will have the capability to serve private IP address dynamically. Most probably you are using a cable modem router or DSL router.
Your comment is not very clear on what you mean by server. Tell me how your set up is configured.