How to install DHCP and WEBMIN

  6 years ago

For this tutorial you will need to have two lan cards(NIC) the first one lan card(eth0) is to connect to the router/modem and the second one (eth1) to connect to switch and to share ips at the local network with the DHCP, before we start to install and config the DHCP I would like to start with Webmin which is a web-based interface for system administration for Linux. We need to edit and add the source list with this command

sudo nano -w /etc/apt/sources.list

I prefer to use the nano editor with the switch “-w,” otherwise the editor textwraps my lines.

At the sources list add the lines and save it with ctr+o and ctr+z to exit:

deb sarge contrib 
deb sarge contrib

You should also fetch and install GPG key with which the repository is signed, with the commands :

cd /root 
apt-key add jcameron-key.asc 

You will now be able to install with the commands :

apt-get update 
apt-get install webmin

Now we will install the DHCP server with this command:

sudo apt-get install dhcp3-server

Now we are going to setup our lan cards with static IPs with this command:

sudo nano -w /etc/network/interfaces

At the eth0 I declare my IP to connect to my router, if you don’t know what your router IP is you can give “ifconfig eth0″ or “route”.

auto eth0 
iface eth0 inet static 

For the eth1 now you can give something like this:

auto eth1 
iface eth1 inet static 

We now save the file and we are going to setup our DHCP server. The first one we need to edit is this one:

sudo nano -w /etc/dhcp3/dhcpd.conf

or if you are using a newer Linux version you can find it here:

sudo nano -w /etc/dhcp/dhcpd.conf

We add comments on these lines. With this symbol # we comment the lines:

# option definitions common to all supported networks... 
#option domain-name ""; 
#option domain-name-servers,; 
#default-lease-time 600; 
#max-lease-time 7200;

Find these lines within the text and edit them like below:

# A slightly different configuration for an internal subnet. 
subnet netmask { 
range ; 
option domain-name-servers;  
#  option domain-name "";  
option routers; 
option broadcast-address; 
default-lease-time 600; max-lease-time 7200; 

In the above example we will share a range of 100 IPs. If we need to share more IPs we need to change the number for example to

Now we declare which lan card will share ips in the local network:

sudo nano -w /etc/default/dhcp3-server

or if you are using a newer Linux version you can find it here:

sudo nano -w /etc/default/isc-dhcp-server 

We add “eth1″ and be careful don’t remove the symbols.


Save it and edit this file now to forward the IP:

sudo nano -w /etc/sysctl.conf

Remove the comment from this line:


Now save this file and reboot your server. You need to connect your clients to the switch and  use the command ifconfig to see if the clients have taken the IP from the server.

Now if you want your clients to connect to the internet you must setup your firewall, so go to your browser and write this :

You must give your IP which you have set up, your eth0 or the name of your server.

You must use your root username and password to log in which you use on your Linux Server. Now go to  NETWORKING -> LINUX FIREWALL then go to and set up the eth0 as NAT card and also activate on boot. Save them and restart the server.