11

I'm having trouble configuring and starting ISC DHCP server on my machine. I'm running Ubuntu 11.10 desktop edition. I installed ISC DHCP by running

$ sudo apt-get install dhcp3-server

My machine has two NICs:

eth0, which is connected to a router for Internet access, that has an IP address of 192.168.2.2. eth1, where I want dhcpd to serve requests, for a subnet.

I have modified /etc/default/isc-dhcp-server to point to eth1:

$ cat /etc/default/isc-dhcp-server
# Defaults for dhcp initscript
INTERFACES="eth1"

I have configured dhcpd for a simple subnet:

$ cat /etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;

subnet 192.168.0.0 netmask 255.255.255.0 {
  interface eth1;
  range 192.168.0.50 192.168.0.100;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.0.255;
}

With this configuration, dhcpd fails to start for me:

$ sudo /etc/init.d/isc-dhcp-server start
* Starting ISC DHCP server dhcpd
* check syslog for diagnostics.               [fail]

$ tail /var/log/syslog
Aug 15 15:29:45 eptc4 dhcpd: No subnet declaration for eth1 (no IPv4 addresses).
Aug 15 15:29:45 eptc4 dhcpd: ** Ignoring requests on eth1.  If this is not what
Aug 15 15:29:45 eptc4 dhcpd:    you want, please write a subnet declaration
Aug 15 15:29:45 eptc4 dhcpd:    in your dhcpd.conf file for the network segment
Aug 15 15:29:45 eptc4 dhcpd:    to which interface eth1 is attached. **
Aug 15 15:29:45 eptc4 dhcpd: 
Aug 15 15:29:45 eptc4 dhcpd: 
Aug 15 15:29:45 eptc4 dhcpd: Not configured to listen on any interfaces!

Am I missing a step? I don't understand why dhcpd is complaining that it's not configured to listen on any interfaces.

This is my first time setting up DHCP. I've spent three days reading manuals and forums and think I've done everything right, but keep getting the same error. Any tips to get me on the right track are greatly appreciated!

Rotem jackoby
  • 165
  • 1
  • 7
Vivek
  • 113

3 Answers3

9

In short: you need to set up an address on interface eth1 before the DHCP can serve requests from it.

Longer story: the DHCP server will read the configuration file, then match the subnet declarations with IP addresses currently assigned to interfaces. Only interfaces whose IP address matches a subnet declaration will serve requests for that subnet. Hence, you need to set up eth1 with an address in the 192.168.0.0/24 range, if you want the ISC DHCP server to serve requests for 192.168.0.0/24 from it.

  • Thank you Riccardo! I updated /etc/network/interfaces, ran ifup eth1, and restarted dhcpd successfully. I knew I was missing some step but didn't understand the process enough to know what that was exactly. Your answer is practical and insightful. – Vivek Aug 15 '11 at 12:55
  • It's same for isc-dhcp-server – iman Mar 19 '21 at 13:35
2

Below worked for me in Ubuntu 12.04

apt-get remove --purge dhcp3-server
sudo apt-get install isc-dhcp-server

Go to /etc/dhcp. create a new file "dhcp.conf" Before that keep a backup of existing "dhcp.conf" file

Add the below details to new dhcp.conf file

# Sample /etc/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "mydomain.example";
subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.10 192.168.1.100;
    range 192.168.1.150 192.168.1.200;
} 

Now go to /etc/defaults/isc-dhcp-server and add your interface name to the file isc-dhcp-server

Modify the /etc/network/interfaces file with your server static details as similar to below

auto eth1
iface inet eth1 static
    address 192.168.1.149
    netmask 255.255.255.0
    gateway 192.168.1.255
    dns-nameservers 192.168.1.1

After this run sudo /etc/init.d/isc-dhcp-server restart and sudo /etc/init.d/networking restart

Note: Dont forget to install dhcp client in your client system. Also after installing dhcp-server in your server system, remove the system from the external network so that it will not harm other devices already in the network, other than the particular client you are interested in

Now if you connect your client to the same network where your server is hosted, the client will acquire an ip with in the specified range

Parto
  • 15,325
  • 24
  • 86
  • 117
LAMOHAN
  • 41
0

Another way to start dhcp-server is possible using service utility.

For example:

# sudo service isc-dhcp-server start