Thursday, July 24, 2014

Setting up DHCP Server in FatDog64

In this article we will look into DHCP Server installation with FatDog64 full install. By default, FatDog64 comes with the DnsMasq package, which can be configured as a basic DHCP server. You can find plenty of articles on how to setup DnsMasq as a DHCP Server, here, here and here. But if you need a full blown and dedicated DHCP Server with advanced options, use ISC-DHCP-Server, which is a free package from Internet System Consortium.

This article assumes, you already owns the below:

a. A True Full Install of FatDog64

If you’re not, you can follow this tutorial to have a fully working install.

b. Development Libraries have been setup for your installation

If you’re not, you can follow step #4 to #7 in this article to have the build environment ready for your FatDog64 installation.

c. Kernel Sources and Headers have been setup for your installation

If you’re not, you can follow step #4 to #7 in this article to have the build environment ready for your FatDog64 installation.

 

Ok lets dive into the implementation.

1. Download ISC-DHCP-Server Source from Internet System Consortium

Note: You can read more on installation from here (Official link)

Download it from this official page. Scroll to bottom, expand ‘ISC-DHCP’ section, then you can see the different versions that are available for download. We took the current version. For convenience here is the direct link to the download,  which starts the download instantly.

image

Put the downloaded archive file (dhcp-4.2.6.tar.gz) in ‘/Packages’ folder.

image

Now extract the contents.(Right Click->Extract Tarball)

2. Build ISC-DHCP-Server Source Code

Go inside the extracted folder and open a terminal there. Type in the below command.

“bash ./Configure”

This command will identify your linux installation and verify the build environment. If everything work fine it will recommend you to make your build. Otherwise you’ve to trouble shoot the issues.

image

Once the configure returns successfully, make the sources using below command.

“make”

image

‘make’ will take some time, so be patient.

3. Install ISC-DHCP-Server

Once ‘make’ command returns, install it using,

‘make install’

image

This will install your DHCP server and copies the ‘dhcpd’ to ‘/usr/local/sbin/dhcpd’.

4. Download and Integrate Custom Scripts to manage ISC-DHCP-Server

Now we need to have some custom scripts to manage the DHCP server, like start, stop and restart the server as a daemon. For your convenience, we’ve shared the scripts here. Just download it to ‘/Packages’ folder.

Note: We’ve inspired by the scripts available in Lubuntu, and rebuilt it based on those.

Now extract it to the same folder.

image

image

Move into the extracted folder and Type in the below commands

“cp –a ./* /”

image

Now the ISC-DHCP-Server installation is ready with your FatDog64. Now you’ve to edit it’s configuration as per your system environment.

5. Configure ISC-DHCP-Server settings

Navigate to ‘/usr/local/etc/ISC-DHCP-Server/Config’ folder.Open ‘DHCP-Server.conf’ file.

image

Now as per your environment, update the sub-net settings in this configuration file. Basically setting up the sub-net information with DHCP server, is a major topic on it’s own respect. If you’re new to this, this article will provide you a fare introduction to start with. Or you can refer the original ISC documentation here

If you’re feeling difficult to follow those documentation, the below settings will be fare enough for your environment, that will be discussed in detail here.

See the lines, which are marked in green. The first line starts with ‘subnet’ defines, one subnet to which our DHCP server should serve IP addresses. The defined subnet (192.168.1.0), is a ‘Class-C’ network address, that represents the subnet (i.e all addresses with the last octet as 0, is the address of the network itself). Now the second line (starts with ‘option routers’, define the gateways for your network. i.e Your primary router’s IP address. This can be your FatDog64 installation, if its directly connected internet. Or it can be of your Router Device’s, that’s connected to the internet. In our case, it’s a ‘iBall ADSL Router’, with IP 192.168.1.1. This is our primary gateway to internet. Again ‘domain-name-servers’ will be the same as our gateway.

Now the ‘range’ section, define the range of IP’s, that will be served by the DHCP server, to the clients. In our case, IP’s range from 192.168.1.51 to 192.168.1.59, will be served. So a total of 9, clients can be served.

Note: you can configure multiple subnets. The official documentation describes that in details.

image

Now close the file. Move to the parent folder, and open ‘Env.conf’ file.

image

Now edit the ‘INTERFACES’ variable to point to your network interface name, through which the DHCP server should listen for DHCP requests and serve IP’s. You can easily check your network interface name using the command ‘ifconfig’ in the terminal. Most often it will be ‘eth0’. If you’ve more than one network interfaces, you can list it here, with a space in between, like “eth0 eth1 br0”.

image

Below figure will help you to understand our current environment, that we’ve described in the example above.

image

6. Test your ISC-DHCP-Server settings

Now it’s the time to test your DHCP server. Open up a terminal in the same folder and issue the below commands.

‘bash dhcp-server start’

‘bash dhcp-server restart’

‘bash dhcp-server stop’

First command will start the server. Second command is to restart the server and the third one to stop the server. If you’ve done it all well, you should get the responses as in the below figure.

image

7. Configure ISC-DHCP-Server on Startup

Now configure the DHCP Server to run on startup, by adding the below line to ‘/etc/rc.d/rc.local’.

“/usr/local/etc/ISC-DHCP-Server/dhcp-server  start”

image

image

8. Verify ISC-DHCP-Server Installation

Now you can fire up any PC’s connected to your network, which can be configured to get it’s IP through DHCP and verify that, it is getting a valid IP from your DHCP server, by looking into the ‘/var/db/dhcpd.leases’ file.

In our case, we’ve configured a windows XP, PC to get it’s address through ‘DHCP’ and verified that it leases valid IP address from the DHCP Server.

As you can see below, the Windows XP PC, got the first available IP address (192.168.1.51). It also got the correct ‘subnet mask’, Default Gateway Address, DNS Server Address details (Which are configured as per step#5, in the configuration files of DHCP-Server). Also please note, the IP Address of the ‘DHCP Server’ is listed as 192.168.1.50, which is our FatDog64 installation. The default gateway is ‘192.168.1.1’, which is the ‘iBall Router’.

image

image

2 comments:

  1. Thanks to 'Martin' for letting us know about the existence of the 'DnsMasq' package in the FatDog64, which can be configured as a basic DHCP Server.

    You can follow the discussion in this Puppy Linux discussion forum.

    ReplyDelete
  2. This post is likeable, and your blog is very interesting, congratulations

    ReplyDelete