How to configure DHCP for special cases…
The PublicIP system is a great system “out of the box” but there are times when you might need to perform some specialized changes that are not available in the normal system. You may need to allow unauthenticated access for several machines but want to have them configured using DHCP instead of setting them up in a STATIC IP configuration because you use them in different locations and the IP address information for the wireless connections change. You might need to configure some machines for local operation but don’t want the hassle of configuring IP address information for whatever reason.
The method to use to perform this feat of magic works on the “hook” that is in the PublicIP system which allows us to execute a script file once the system is configured at the end of the bootup operation. The following is a description of “how” to accomplish re-configuring the DHCP server in the zonecd machine to allow you the ability of configuring specific machines on the wireless side for a specific DHCP supplied IP and other information that may be needed. If you look at a zonecd machine in the /etc directory after it is booted up and running you will find a file called “dhcpd.conf”. The file is used by the DHCP server to configure the IP address pool the DHCP server uses to determine what IP’s are available for use, the netmask, gateway and DNS settings to send to a DHCP client requesting a DHCP supplied IP address (the wireless client’s machine makes such a request when running in DHCP mode) and how long the “lease” time is before the client requests a lease update.
Since the zonecd machine configures the dhcpd.conf file during it’s normal bootup operation we will have to “re-construct” a replacement dhcpd.conf file with the information we want to include in order to effect the changes we wish to have in the system when DHCP requests are made to the zonecd machine. Not only do we need to make the changes to the dhcpd.conf file we also have to “restart” the dhcp server running on the zonecd machine for the changes to take effect. The dhcp server does not have any commands to “re-read” it’s configuration file so we have to stop the dhcp server then start it back up for the dhcp server to read the information we placed in the dhcpd.conf file so our changes take effect.
Modifying the dhcpd.conf file:
Since we know we have to make some additions to the dhcpd.conf file in the system we will use some commands within an executable script. As an example let’s say you are wanting to configure a laptop for a specific IP address so you can use unauthenticated access on that laptop but you don’t want to have to configure the laptop each time for the spacific static IP address you have assigned for the unauthenticated access by the laptop. Here is the information we need to supply. One piece of information we will need from the laptop is the MAC Address of the wireless interface in the laptop. The dhcp server will use the MAC address of the laptop to determine if a specific configuration is being sent to the laptop.
Assigned IP address for unauthenticated access: 10.10.10.50
Laptop wireless interface MAC Address: 00:04:6F:04:6F:01
With these two pieces of information we can construct a command for the dhcp server in the zonecd machine to issue the specified IP address to the laptop with the specified MAC Address. In the /etc/dhcpd.conf file we need to place the following lines at the end of the existing file to allow the dhcp server to perform this feat of magic:
# comment – laptop static IP address for unauthenticated access
host laptop1 {
hardware ethernet 00:04:6F:04:6F:01;
fixed-address 10.10.10.50;
}
Now – what does all of that mean?
OK – Now we need to get this information into the dhcpd.conf file AND restart the dhcp server. Here are the steps required to do this. All of the following steps are executed in a terminal window (if you are using the GUI) or on the command line if you are using NOX mode:
If you already have a /mnt/floppy/zonecd/init.sh script file on the sytem you not need perform step 1 and 2 and in step 3 you will not need the first three lines and only have to “add” the commands required to implement the change to the /etc/dhcpd.conf file and restart the dhcp server.
If you don’t have the init.sh file then you will need to perform all of the following steps:
1. Create a file called init.sh in the /mnt/floppy/zonecd directory:
touch /mnt/floppy/zonecd/init.sh
2. Change the permissions on the init.sh file to allow execution by the system when it boots up:
chmod 755 /mnt/floppy/zonecd/init.sh
3. Start a text editor called nano and insert the commands into the init.sh script file needed to implement the changes to the dhcp server on the system:
nano /mnt/floppy/zonecd/init.sh
Type the following into the text editor:
#!/sh/bin
#
# dhcpd server additional configuration and restart
#
echo ”
# comment – laptop static IP address for unauthenticated access
host laptop1 {
hardware ethernet 00:04:6F:04:6F:01;
fixed-address 10.10.10.50;
}
#
# end of definitions ” >> /etc/dhcpd.conf
#
# Add any more devices using the same as above – use different host names and IP addresses
#
# restart the dhcpd server for eth1 – can not use SIGHUP (dang it!)
#
pkill -TERM dhcpd-2.2.x 2>>/tmp/init.log
#
sleep 2
#
echo -n “Re-Starting DHCP…”
if /usr/sbin/dhcpd -q eth1 2>>/tmp/init.log; then
echo ” OK”
echo “Re-Starting DHCP for fixed IP insertions… OK” >>/tmp/init.log
else
echo ” FAILED”
echo “Re-Starting DHCP for fixed IP insertions… FAILED” >>/tmp/init.log
fi
You have reached the end of what you need to type in the line above this one!
3. Save the init.sh file by pressing ctrl-x (press the Ctrl-key and hold it down while pressing the x key on the keyboard), answer Yes to the question asked if you want to save the file.
OK – we now should have an executable script file called init.sh in the /mnt/floppy/zonecd directory!
Here is a quick way to test it!
Type the following to execute the init.sh script file:
/mnt/floppy/zonecd/init.sh
You should see messages saying the dhcpd server was stopped then restarted. That is a good thing if you do and if you don’t you need to go back over the above steps to see where you might have mis-typed something.
If you did get the messages and the dhcpd server started OK take the laptop you used and connect to the system wirelessly. Once you have established a wireless connection check to see if the IP address was indeed assigned to the laptop.
That is all that is needed to setup a specific IP address to a laptop. If you want to add more laptops to the list then you will need to repeat the “host” part of the commands used above – don’t forget each device MUST use a different host name and make sure you have the {} in the proper places as well!
One more thing – DON”T assign an IP address that is within the range of the dhcp server for it’s address pool – this can cause some strange types of problems so it is best to avoid it. You can see what the dhcp address pool is by looking at the /etc/dhcpd.conf file.
If you want more information on what you can do in the dhcpd.conf file google for “dhcpd.conf” and you will find all sorts of information on the proper use of the file. You can also look here: http://linuxreviews.org/man/dhcpd.conf/ for a formal definition of the dhcpd.conf configuration file.
I hope this info is clear – if not please leave comments so I can correct any errors or omissions in the steps!