Networking with DHCP

I just purchased Mandrake 7.0 and got it running on a new computer. I have a home network of five workstations and would like them to be all configured to use DHCP. Can you help me do this?

Tech Support Netcfg 1
Figure One: You can use netcfg to configure names, hosts, interfaces, and routing for your DHCP server.

I just purchased Mandrake 7.0 and got it running on a new computer. I have a home network of five workstations and would like them to be all configured to use DHCP. Can you help me do this?

No problem. The first thing we need to do is determine which computer will be the DHCP server. If your new Linux computer will be doing the work, then we will probably want to give it a Static IP address. Once you have the computer up and running, you can use the netcfg utility that comes with every distribution. Just bring up an xterm and su to root. Then type netcfg.

netcfg allows you to configure four basic areas — names, hosts, interfaces, and routing. In each section, fill in all the information that is relevant to your setup. For this example, I am using a class “B” IP scheme and will set the DHCPD server to the static address (See Figure One.)

You will need to edit the properties of the eth0 interface on your Linux machine, which can be done by clicking on the interfaces button and then the edit button. Enter the static IP address you want to use for your internal address. Make sure to save your changes. Next, you will need to “deactivate” the interface, and then reactivate it from netcfg’s Interfaces tab. If everything has been entered correctly, the interface should appear in netcfg itself, labeled as “active.” Exit out of netcfg and type /sbin/ifconfig to ensure that the information you just entered has been properly bound to the interface. ifconfig should show you the information you just entered. So for me, it would look like Figure Two.

Figure Two: Sample Output of ifconfig

eth0 Link encap:Ethernet HWaddr 00:00:86:3B:8C:76
inet addr: Bcast: Mask:
RX packets:30553 errors:0 dropped:0 overruns:0 frame:0
TX packets:7087 errors:0 dropped:0 overruns:0 carrier:4
collisions:0 txqueuelen:100
Interrupt:3 Base address:0×300

If the information looks correct, it’s time to configure DHCP. First, you should make sure that you have the correct DHCP package installed on the server. This is where things get a little confusing, but usually the package that is installed is the DHCP client (DHCPCD), but not the server. So do a quick search to make sure that you’ve got the server installed. The fastest way to do this is with RPM. Just type rpm -qi dhcp, and that will look to see if you have the server package installed. If it’s not there, you will need to install it. Luckily, it most likely came on the same disk your distribution came on, so it should be as easy as popping in the CD and installing it from there. If you are not entirely familiar with installing packages, check out this month’s Newbies column, pg. 28.

Even after you’ve installed the server, there is still one missing file that you will need to create by hand. This is the dhcpd.conf configuration file. To create it, just su to root and type the following:

cd /etc
touch dhcpd.conf
chmod 644 dhcpd.conf

Now that the master configuration file has been created and the permissions are all set, all we have to do is set up the information that will be dynamically allocated to the client machines. To keep things simple, we are just going to set up general network information like IP addresses, subnet masks, and the type of network. You will need to add this to the file manually using your favorite text editor. To do this, open up the /etc/ dhcpd.conf file and type in the lines shown in Figure Three.

Figure Three: Adding Info to dhcpd.conf


This will allocate IP numbers to any DHCP client within the - address range. This is more than ample for a five-client network. Once this is in place, you will need to test the configuration and ensure that the clients are getting the correct information. To get the DHCPD server running, type:

/etc/rc.d/init.d/dhcpd start

Tech Support Ntsysv 2
Figure Four: You can use ntsysv to add links to your run levels, allowing dhcpd to start at boot time.

This will start the server, but the service will not automatically be re-started on the next reboot. In order to make that happen, you need to add some links to the various run levels under the /etc/rc.d directory. This can be done most easily with a nice little utility called ntsysv. (See Figure Four.)

Just su to root, and then type ntsysv. The utility will pop up in your xterm window and you just need to select DHCPD from the menu. Once that’s done, you are ready to go. Restart your client’s network services and see if they pick up the 10.1.x.x IP number.

DHCPD can provide the client machines with much more information than we set up here in this example. You can read more about it in the documentation that comes with the package, or in the HOW-TO that can be found at the Linux Documentation Project (http://www.linuxdoc.org). Good luck.

App Tips

Tech Support Photogenics 3
Tech Support GIMP Screen 4

This month I was doing some graphical work and happened to stumble upon a few programs that have made my work a little easier and a lot more fun. Check them out if you get a chance:

* Photogenics — This package stunned me. I thought I was back on a SGI workstation again. Photogenics is a graphics/art tool that allows the user to create images from scratch, modify existing images, or even blend the two together. It also performs many simple graphical tasks like file conversions and photo touch-up work. For a graphic artist, the sky is the limit. http://www.paulnolan.com/Linux/download.html

* GIMP — If you don’t know about the GIMP yet, you should. The GIMP is an extremely popular graphics manipulation tool for Linux. In fact, GIMP stands for “Graphical Image Manipulation Program.” Although most people just have fun saying “bring out the GIMP!” I have used it for many projects; it continues to impress me with all of the options, tools, and plug-ins that are made freely available for it. I give it a big thumbs up. http://www.gimp.org/download.html

Gaylen Brown is a senior consultant at Linuxcare, Inc. He can be reached at tech@linux-mag.com.

Comments are closed.