i am new bie to Linux and wants to configure complete DHCP server and how I can assign ips to clients on Ubuntu or windows machine. will it connect clients automatically to my Linux Ubuntu machine or I may give some configuration.
1 Answer
use command ifconfig to check whether your machine has DHCP or STATIC IP
auto eth0
iface eth0 inet dhcp
In this type of reply your machine has dhcp IP convert it to static first
First assign static ip to your server
sudo nano /etc/network/interfaces
it will open the file and insert ip's of your choice or provided by ISP
auto eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameserver 182.176.39.23 182.176.18.13
After closing the file Check it via command
cat /etc/network/interfaces
Now restart your interface
sudo ifdown eth0
sudo ifup eth0
Now install the dhcp server
sudo apt-get install isc-dhcp-server
now set the interface through which the dhcp server will listen the clients
sudo nano /etc/default/isc-dhcp-server
...In INTERFACE “eth0” <--<< type your NIC through which you will assign DHCP IP.
Now configure dhcp setting
sudo nano /etc/dhcp/dhcpd.conf
Add the following lines
# A slightly different configuration for an internal subnet.
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.60;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1, 182.176.39.23, 182.176.18.13;
default-lease-time 600;
max-lease-time 7200;
If you are running DNS server on your system then enter the domain name and name server in dhcpd.conf file for example As i explained in BIND9 DNS CONFIGURATION I have DNS server named nefitari.autun.hom and IP address is 192.168.1.5 like as under
option domain-name “nefitari.autun.hom”;
option domain-name-server 192.168.1.5;
Now start/restart dhcp server
sudo /etc/init.d/isc-dhcp-server start
If it gives you error like Ignoring unknown interfaces eth0=eth0 just do it again
Sudo /etc/init.d/networking restart
*reconfiguring network interfaces [ok]
Now lease an ip address from dhcp server
Sudo dhclient
The DHCP server writes all current IP address "leases" to the file /var/lib/dhcp/dhcpd.leases so you should also find the lease there:
Sudo nano /var/lib/dhcp/dhcpd.leases
To releases the current lease *once the lease has been released, the client exits.
sudo dhclient -r
Now obtain fresh IP:
sudo dhclient