Setting up DHCP server

From Ndiyo

Jump to: navigation, search

Nivos need to be allocated an IP address before anything can talk to them over the network. The thing that does the allocating is a DHCP server. (DHCP stands for 'Dynamic Host Configuration Protocol'; it's a protocol that dynamically assigns an IP address to a computer on a network.)

Most networks will already have a DHCP service - in a home environment it might be provided by a broadband router, for example. You should normally only install a DHCP server if you don't already have one on your network, or if you are installing a Two-Interface System, where the Nivos will be on a separate network of their own and will not be seen by any other DHCP servers.

The full details of how to configure DHCP serving are beyond the scope of this manual. More information can be found here. However, let us consider a system where the Nivos are connected to the first ethernet interface, eth0, and a connection to the outside world, if any, is made through a second ethernet interface eth1, or a different type of interface such as wireless or satellite.

Image:Dual-ethernet system.png

[edit] Setting up the interfaces

The first thing action to allocate a static IP address to the first interface eth0. This can be done using the System > Administration > Networking control panel in Ubuntu, or by editing the file /etc/network/interfaces so that it contains something like the following details for eth0:

 auto eth0
 iface eth0 inet static
 address 192.168.200.1
 netmask 255.255.255.0

If you are connecting to the outside world using eth1, you should also configure that. In many cases, you will be plugging eth1 into a network which provides DHCP, so you would need:

 auto eth1
 iface eth1 inet dhcp

Again, you may prefer to do this using the GUI-based tools. If you have changed an interface's details by editing the configuration file directly, you will need to restart that connection so it can pick up the new settings. For example:

 $ sudo ifdown eth0
 $ sudo ifup eth0

[edit] Installing a DHCP server

Install the dhcp3-server package using the method of your choice. e.g, in the terminal window, type:

  $ sudo apt-get install dhcp3-server

The installer may try to start the server and tell you it's failed. Don't worry!

Edit /etc/default/dhcp3-server to tell the server it should operate on interface eth0. The line defining INTERFACES should look something like this:

 INTERFACES="eth0"

Then you'll need to edit /etc/dhcp3/dhcpd.conf to specify the details of the server's operation. This file looks daunting, but don't worry, we only need a very simple set of instructions. You can comment out all of the lines in this file, or delete them, and then add this to the bottom:

 subnet 192.168.200.0 netmask 255.255.255.0 {
     range 192.168.200.2 192.168.200.100;
 }

This tells the server that DHCP requests coming in on the 192.168.200.* network (which is what we configured eth0 to use) should be allocated IP addresses in the range 192.168.200.2 to 192.168.200.100.

You should then be able to restart the DHCP server using the following command in the terminal:

  $ sudo /etc/init.d/dhcp3-server restart

and any Nivos connected to the eth0 network should then display an IP address on booting. If you're connecting anything else to this side of the network you may need a more complex DHCP configuration, but this should be enough for Nivos.

wiki navigation
ndiyo project