UBUNTU DHCP not assigning IP address to clients
Ensure that you have cached the latest version of network-manager and network-manager-gnome packages in /var/cache/apt directory.
Failure to do so will create very serious issues as you won't be able to access INTERNET.
How to do it : http://www.tuxradar.com/answers/517
I performed a minimal install so I had it in my cache. Then remove network-manager and network-manager-gnome using following command.
sudo apt-get purge network-manager network-manager-gnome
Then again reinstall and reboot
sudo apt-get install network-manager network-manager-gnome -y && reboot
Find the network interface on which you want to run DHCP server by running the following command in terminal. In my case it was enp2s0. It can be eth0, eth1, etc
ifconfig -a
Now comes the main part. Edit the /etc/network/interfaces file.
sudo gedit /etc/network/interfaces
OR
sudo nano /etc/network/interfaces
Paste the following :
allow-hotplug enp2s0
iface enp2s0 inet static
name Lan
address 192.168.1.33
netmask 255.255.255.0
network 192.168.1.0
Replace enp2s0 by your network interface and make other necessary modifications.
For gedit simply save and exit. Nano users save using ctrl + o followed by return (enter) key. Then exit by ctrl + x.
You must have noticed I used allow-hotplug
instead of auto. It is because in UBUNTU 15.10 (can't speak about other version) during boot UBUNTU waits for all the auto interface to be UP. Owing to it UBUNTU waits for 2 mins 3 sec (in my case) and then completes the boot process. So in order to reduce the boot time and to not encounter this issue I am using allow-hotplug
.
Finally modify the main configuration file as follows :
sudo gedit /etc/dhcp/dhcpd.conf
OR
sudo nano /etc/network/interfaces
ddns-update-style none;
authoritative;
log-facility local7;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.35 192.168.1.100;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.33;
}
The following is for IP reservation. If you want to do it then replace 7c:0b:c6:**:**:43
with mac address of your device.
host TABLET {
hardware ethernet 7c:0b:c6:**:**:43;
fixed-address 192.168.1.34;
}
Again, for gedit, save and exit. Nano users save using ctrl + o followed by return (enter) key. Then exit by ctrl + x.
Notice that in this configuration address 192.168.1.33
of interfaces file above matches with option routers 192.168.1.33
. Similarly network 192.168.1.0
of interfaces matches with subnet 192.168.1.0
. The same goes with netmask and subnet-mask.
As mentioned above by Doug Smythies and due to error in configuration I set IP range from 192.168.1.35 because I reserved an IP address 192.168.1.34. Keeping the same IP address in reserved list and IP range creates problems.
A final reboot won't hurt.
reboot
If you encounter problems then check the service status using
service isc-dhcp-server status
Because I am an inexperienced UBUNTU user I cannot say why it solved the issue but it did and I am sharing this answer so as to help fellow mates like me who are also inexperienced.
Special Thanks to Doug Smythies for your interest and efforts for the solution. Please make necessary changes and corrections.
Related videos on Youtube
Siddharth Manthan
Updated on September 18, 2022Comments
-
Siddharth Manthan over 1 year
I have a minimal knowledge about ubuntu. I am trying to run a DHCP server on UBUNTU so as to share Dongle 3G Internet. I disabled router's DHCP and followed the following guide to setup DHCP server in UBUNTU.
How do I install and configure a DHCP server?
Here's my
/etc/default/isc-dhcp-server
:# Defaults for isc-dhcp-server initscript # sourced by /etc/init.d/isc-dhcp-server # installed at /etc/default/isc-dhcp-server by the maintainer scripts # # This is a POSIX shell fragment # # Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf). #DHCPD_CONF=/etc/dhcp/dhcpd.conf # Path to dhcpd's PID file (default: /var/run/dhcpd.pid). #DHCPD_PID=/var/run/dhcpd.pid # Additional options to start dhcpd with. # Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead #OPTIONS="" # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACES="enp2s0"
And my
/etc/dhcp/dhcpd.conf
:default-lease-time 600; max-lease-time 7200; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.33 192.168.1.200; } host server { hardware ethernet 00:1D:92:EA:DB:3C; fixed-address 192.168.1.33; } host tablet { hardware ethernet 7C:0B:C6:B4:EE:43; fixed-address 192.168.1.34; }
I am assigning static IP to server so as to run bind9 DNS server. My clients can only connect if I configure them to use static IP, but the server doesn't assign them IP if I change static IP option neither UBUNTU gets IP address. Is their any easier approach to achieve this. I am in need of serious help as no client can access internet.
Here's some additional information that might be useful :
My
/etc/dhcp/dhclient.conf
:# Configuration file for /sbin/dhclient, which is included in Debian's # dhcp3-client package. # # This is a sample configuration file for dhclient. See dhclient.conf's # man page for more information about the syntax of this file # and a more comprehensive list of the parameters understood by # dhclient. # # Normally, if the DHCP server provides reasonable information and does # not leave anything out (like the domain name, for example), then # few changes must be made to this file, if any. # option rfc3442-classless-static-routes code 121 = array of unsigned integer 8; #send host-name "andare.fugue.com"; send host-name" /etc/dhcp/dhclient.conf send host-name UBUNTU-DESKTOP; #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c; #send dhcp-lease-time 3600; #supersede domain-name "fugue.com home.vix.com"; #prepend domain-name-servers 127.0.0.1; request subnet-mask, broadcast-address, time-offset, routers, domain-name, domain-name-servers, domain-search, host-name, dhcp6.name-servers, dhcp6.domain-search, netbios-name-servers, netbios-scope, interface-mtu, rfc3442-classless-static-routes, ntp-servers, dhcp6.fqdn, dhcp6.sntp-servers; #require subnet-mask, domain-name-servers; timeout 300; #retry 60; #reboot 10; #select-timeout 5; #initial-interval 2; #script "/etc/dhcp3/dhclient-script"; #media "-link0 -link1 -link2", "link0 link1"; #reject 192.33.137.209; #alias { # interface "eth0"; # fixed-address 192.5.5.213; # option subnet-mask 255.255.255.255; #} #lease { # interface "eth0"; # fixed-address 192.33.137.200; # medium "link0 link1"; # option host-name "andare.swiftmedia.com"; # option subnet-mask 255.255.255.0; # option broadcast-address 192.33.137.255; # option routers 192.33.137.250; # option domain-name-servers 127.0.0.1; # renew 2 2000/1/12 00:00:01; # rebind 2 2000/1/12 00:00:01; # expire 2 2000/1/12 00:00:01; #}
I remember I had edited
/etc/network/interfaces
file.# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback
sudo netstat -uap
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 localhost:54557 *:* 694/Plex Media Serv udp 0 0 MANTHAN-DESKTOP:36172 *:* 694/Plex Media Serv udp 0 0 *:19844 *:* 4017/dhclient udp 0 0 MANTHAN-DESKTOP:40486 *:* 694/Plex Media Serv udp 0 0 *:32410 *:* 694/Plex Media Serv udp 0 0 *:32412 *:* 694/Plex Media Serv udp 0 0 *:32413 *:* 694/Plex Media Serv udp 0 0 *:32414 *:* 694/Plex Media Serv udp 0 0 *:1900 *:* 966/Plex DLNA Serve udp 0 0 *:1901 *:* 694/Plex Media Serv udp 0 0 MANTHAN-DESKTOP:domain *:* 2749/dnsmasq udp 0 0 *:bootpc *:* 4017/dhclient udp 0 0 *:bootpc *:* 3425/dhclient udp 0 0 192.168.42.2:netbios-ns *:* 900/nmbd udp 0 0 MANTHAN-DESK:netbios-ns *:* 900/nmbd udp 0 0 *:netbios-ns *:* 900/nmbd udp 0 0 192.168.42.:netbios-dgm *:* 900/nmbd udp 0 0 MANTHAN-DES:netbios-dgm *:* 900/nmbd udp 0 0 *:netbios-dgm *:* 900/nmbd udp 0 0 *:43227 *:* 966/Plex DLNA Serve udp 0 0 MANTHAN-DESKTOP:33368 *:* 694/Plex Media Serv udp 0 0 localhost:49934 *:* 694/Plex Media Serv udp 0 0 *:37737 *:* 966/Plex DLNA Serve udp 0 0 *:13495 *:* 966/Plex DLNA Serve udp 0 0 *:42239 *:* 3425/dhclient udp6 0 0 [::]:17738 [::]:* 3425/dhclient udp6 0 0 [::]:33559 [::]:* 4017/dhclient
NOTE :- BIND9 DNS server is installed in this system but I failed to configure it properly but I hope it has no connection to this problem.
-
Doug Smythies about 8 yearsdhcpd doesn't seem to be running. Are there any messages when you try to start it? Or any log entries anywhere in /var/log?
-
-
Siddharth Manthan about 8 yearsDidn't work... Any other solution.
-
Siddharth Manthan about 8 yearsHere's something. When I remove isc-dhcp-server package all my clients get IP adderss but I don't know from where. The server got IP address 10.42.0.1. I would like to change it and set to static.
-
Siddharth Manthan about 8 yearsThanks for your interest. Problem solved. Should I mention here how it was solved ??