How to set up a DHCP server?

26,740

Solution 1

I think you should look at the official Ubuntu documentation about DHCP server, that explains how to install and configure it:

https://help.ubuntu.com/community/dhcp3-server

Solution 2

The problem is that with the new dhcp3 server that the config files are done differently than on older installations.

Now the installation is done under isc-dhcp-server the location of the dhcpd.conf file and interfaces has changed along with the mechanism to start stop the service.

The dhcpd.conf file has moved from /etc/dhcp3/dhcpd.conf to /etc/dhcp/dhcpd.conf. The interface definition has also moved--from /etc/default/dhcp3-server to /etc/default/isc-dhcp-server.

The fields are basically the same but if you have been modifying the original files you will get the error you see above. Make the mods to these files and you should be OK to go.

Also no best to start and stop using sudo service isc-dhcp-server start/stop/restart.

I was suffering with all these problems on Ubuntu 12.04 but this resolved all the issues and now it's working. I hope this helps you.

Solution 3

I would suggest you to take a look to the man page of /etc/dhcp3/dhcpd.conf, which is the file you'll have to modify to correctly configure your dhcpd server. A basic file would look like this :

DHCPDARGS=eth0; # to specify to which interface your dhcpd server have to listen

subnet 192.168.0.0 netmask 255.255.255.0 {
       option routers                  192.168.0.1; #Default Gateway
       option subnet-mask              255.255.255.0;
       option domain-name              "home.local";
       option domain-name-servers      192.168.0.2;
    range dynamic-bootp 192.168.0.51 192.168.0.100;  #DHCP Range to assign
       default-lease-time 43200;    # every 12 hours, an address can be changed 
       max-lease-time 86400;    # every 24 hours, an address must be renewed 
}
Share:
26,740

Related videos on Youtube

Matthew Wilson
Author by

Matthew Wilson

beer

Updated on September 18, 2022

Comments

  • Matthew Wilson
    Matthew Wilson almost 2 years

    I am currently at this stage of setting up DHCP, and id just like to know what this output in terminal means? I know I have to edit a file but I do not know which one, and I do not know what to put in it. Ultimately I would like to set up a DHCP server.

    matt@matt-R580-R590:~$ sudo tail /var/log/syslog
    Jan  3 17:35:23 matt-R580-R590 dhcpd: Wrote 0 leases to leases file.
    Jan  3 17:35:23 matt-R580-R590 dhcpd: 
    Jan  3 17:35:23 matt-R580-R590 dhcpd: No subnet declaration for eth0 (no IPv4 addresses).
    Jan  3 17:35:23 matt-R580-R590 dhcpd: ** Ignoring requests on eth0.  If this is not what
    Jan  3 17:35:23 matt-R580-R590 dhcpd:    you want, please write a subnet declaration
    Jan  3 17:35:23 matt-R580-R590 dhcpd:    in your dhcpd.conf file for the network segment
    Jan  3 17:35:23 matt-R580-R590 dhcpd:    to which interface eth0 is attached. **
    Jan  3 17:35:23 matt-R580-R590 dhcpd: 
    Jan  3 17:35:23 matt-R580-R590 dhcpd: 
    Jan  3 17:35:23 matt-R580-R590 dhcpd: Not configured to listen on any interfaces!
    matt@matt-R580-R590:~$ 
    
  • djeikyb
    djeikyb over 12 years
    While I share your scepticism over the need for OP's dhcp server, you don't even attempt to answer the question. If you need more info (like, "why do you think you need a dhcp server?") or want to refocus the question to the root problem, leave a comment.
  • Matthew Wilson
    Matthew Wilson over 12 years
    i dont have a /etc/dhcpd.conf file only a /etc/dhcp/dhcpd.conf and /etc/dhcp3/dhcpd.conf file
  • Bebbolin
    Bebbolin over 12 years
    @MatthewWilson : you should eddit /etc/dhcp3/dhcpd.conf