Welcome to my site. Please CLICK HERE to give your opinions regarding this new look of "PCTipsbyAnu". Thanks for visiting.

Saturday, January 8, 2011

Browse » Home » , , , , , , , » How to manually provide IP range for DHCP?

How to manually provide IP range for DHCP?


I have recently configured a DHCP server on my Ubuntu Linux server.Before I was using static IP addresses on each of the laptops thatconnected to my wireless network which wasn't a problem. With theappearance of more public wireless networks it means that I was havingto switch between a static and dynamic address on a regular basis andso DHCP promised to make life easier.DHCP stands for Dynamic Host Control Protocol. It is a protocol thatallows a client computer (in this case my laptops), to request that theserver provides them with an IP address valid for the network theyconnect to. This technique is used by most broadband providers and byany home broadband routers / wireless routers. Due to my Linux firewallI however use a Wireless Access Point, rather than a wireless router,so it does not have DHCP built into it, which is why I need toconfigure it in Linux.

Installation of the dhcp server

To install the server code then use
sudo apt-get install dhcp OR yum install dhcp*
There is also a package dhcp3-server, but I used just dhcp in this case.

Also note that you will most likely already have dhcpcd,dhcp-client or dhcp3-client already installed, which is used to acquirea DHCP address for the local machine and not provide the serveraspects.

The computer may tray to automatically start the server, but it will most likely fail until configuration is complete.

Configuration of the dhcp server

The first file to edit is /etc/default/dhcp
This has an entry:

INTERFACES=""

which needs to be edited to list the interfaces that the servershould listen for. In my case the local network is eth1 (eth0 is myInternet connection), so my entry is:
INTERFACES="eth1"
The other file is the main configuration file /etc/dhcpd.conf

The first part of the file contains some default values that will beapplied to any addresses given out.
An important entry is the NameServer entry:
option domain-name-servers <address1>, <address2>;
The addresses of your DNS servers is normally provided by your ISP.Two servers are normally listed as this provides built-in redundancy inthe protocol. Your name servers may be listed in /etc/resolv.conf ifyou don't know what they are.
Then there are some sections that describe how addresses are to begiven out. These are all commented out by default, an example is shownbelow:
subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.10 192.168.1.250;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
}
This example uses the private address range 192.168.1.0/24.
Therange of addresses allocated starts at .10, and goes up to .250, whichleaves a few addresses at the top and bottom of the range that can beallocated to static devices (e.g. my server / Wireless Access Pointetc).

The routers entry needs to point at the gateway to the Internet which is the address of my Linux server in this case.
The server can then be restarted using:

sudo /etc/init.d/dhcp

Look in the system log /var/log/syslog if the daemon fails to start.

If you are running a firewall you may need to add a rule to allowthe DHCP traffic to reach the server, but other than that configurationis complete and any computers set to automatically request their IPaddress should be allocated an address in the specified range.

You can see any IP addresses handed out in the file: /var/lib/dhcp/dhcpd.leases

Advanced Configuration

This concludes the basic configuration for the DHCP server, butfurther options allow for specific IP addresses to be allocated tocertain machines (based on their MAC address), or for differentaddresses / routing / DNS information based up the interface that theyconnect on etc.

More information is available from

man dhcpd

and
man dhcpd.conf

Thanks...
You can leave a response, or trackback from your own site.

About 'Anu': My name is 'Anu' also Known as 'ANU 007 TIGER' .I'm administrator of 'PC Tips by Anu' blog .This blog was opened for sharing contents about hacking n cracking.
Thanks YAHOO OR GMAIL

0 comments:

Post a Comment

 
Back to Top