Pages

Banner 468 x 60px

 

Jumat, 02 November 2012

Configure your Ubuntu Server as a DHCP server

0 komentar

Configure your Ubuntu Server as a DHCP server


Now it’s time to get a bit deeper in the trenches by configuring that same Ubuntu server to serve up DHCP addresses. You might think this is a difficult setup, but it’s not. And many might be asking “Why do this when my router does the trick?” Most routers do a good job of serving up DHCP addresses. But there are times when those routers aren’t as configurable as we’d like them. Or maybe you want your DHCP server/router to also act as a much stronger firewall than what a standard router can handle. In these cases it’s nice to be able to set up your own DHCP server. And in this article, we will do just that.
Nuts and bolts
The information you should know about the DHCP server in this article looks like this (for examples’ sake):
  • ethernet device: eth0
  • IP Address range: 192.168.1.100 – 192.168.1.200
  • Subnet address: 192.168.1.0
  • Netmask: 255.255.255.0
  • DNS Servers: 208.67.222.222 and 208.67.220.220 (OpenDNS for those who do not know)
  • Domain: my.example.net
  • Gateway Address: 192.168.1.1
  • Broadcast Address: 192.168.1.255
What you will need to do install the dhcp3-server package in order to serve up the addresses. To install this issue the command:
sudo apt-get install dhcp3-server
You will need to enter your sudo password for the installation to begin. When the installation is complete you will have the configuration file (dhcp3-server) located in /etc/default/ and the executable command (dhcp3-server) will be located in /etc/init.d/.
Before you fire up the server you first must handle some configuration.
Configuration
The first configuration is to set the ethernet device. Open up the configuration file with the command:
nano /etc/default/dhcp3-server
On line 11 of this file (Which is actually the last line because this file is basically empty) you will see the line:
INTERFACES=”"
Change this line to read:
INTERFACES=”eth0″
You are finished with this file. Save the file and then open up the file /etc/dhcp3/dhcpd.conf. The first line you will need to edit is line 16. This line will look like this:
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
You need to comment out all of those lines so they look like:
# option definitions common to all supported networks...
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
#default-lease-time 600;
#max-lease-time 7200;
Now go down to line 53. Here you will see this section:
# A slightly different configuration for an internal subnet.
#subnet 10.5.5.0 netmask 255.255.255.224 {
#  range 10.5.5.26 10.5.5.30;
#  option domain-name-servers ns1.internal.example.org;
#  option domain-name "internal.example.org";
#  option routers 10.5.5.1;
#  option broadcast-address 10.5.5.31;
#  default-lease-time 600;
#  max-lease-time 7200;
#}
This section needs to be uncommented out and edited to reflect this:
# A slightly different configuration for an internal subnet.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option domain-name-servers 208.67.222.222, 208.67.220.220;
option domain-name "my.example.net";
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
Save this file and you are ready to fire up your DHCP server.
Starting the service
To start the DHCP server issue the command:
/etc/init.d/dhcp3-server start
You should see no errors. Once your server is up and running go to one of your machines and restart the networking. You should get a new IP address as well as the DNS addresses configured. If your machine does not find the server you may have to configure the DHCP server IP address. This should not be necessary, but it’s good to know in a pinch.
Final thoughts
You probably didn’t realize how simple it would be to set up a DHCP server did you? Now you know. This set up should make for a very reliable DHCP server for your internal network.

0 komentar:

Posting Komentar

wewen06. Diberdayakan oleh Blogger.