Why do I get "No subnet declaration" starting ISC DHCP server on subinterfaces?

I have created two subinterfaces on eth0 :

  • eth0:0 with IP 192.168.10.1/24
  • eth0:1 with IP 192.168.11.1/24

Configured /etc/dhcp/dhcpd.conf like that:

option domain-name-server 194.204.159.1;

subnet 192.168.10.0 netmask 255.255.255.0 {
   option routers 192.168.10.1;
   option subnet-mask 255.255.255.0;
   range 192.168.10.10 192.168.10.100;
}

subnet 192.168.11.0 netmask 255.255.255.0 {
   option routers 192.168.11.1;
   option subnet-mask 255.255.255.0;
   range 192.168.11.10 192.168.11.100;
}

But when I try to start DHCP server I'm getting:

No subnet declaration for eth0:0 (no IPv4 addresses).
 ** Ignoring requests on eth0:0.  If this is not what
    you want, please write a subnet declaration
    in your dhcpd.conf file for the network segment
    to which interface eth0:0 is attached. **

No subnet declaration for eth0:1 (no IPv4 addresses).
 ** Ignoring requests on eth0:1.  If this is not what
    you want, please write a subnet declaration
    in your dhcpd.conf file for the network segment
    to which interface eth0:1 is attached. **

Config in /etc/default/isc-dhcp-server:

INTERFACES="eth0:0 eth0:1"

What is wrong with that?

UPDATE:

Forgot to mention that I'm trying to configure router-on-a-stick on subinterfaces(aliases?). I set up 2 hosts with 192.168.10.2 and 192.168.11.2 and after configuration the 3rd host with subinterfaces eth0:0 and eth0:1 is forwarding packets between these 2 host. But now I'm trying to configure DHCP server which can dynamically assign IPs to 2 hosts in 2 subnets.


Solution 1:

This will not work, as IP aliasing is just a method to add an address to an existing interface. What you probably should do here is VLANs.

Solution 2:

You do not need to have sub-interfaces to serve DHCP requests for those network. http://manpages.ubuntu.com/manpages/hardy/man5/dhcpd.conf.5.html

DHCP is a protocol like TCP/IP is, so it works on a level before the machines even have IP addresses, therefore you don't need to listen on the sub-interfaces for DHCP requests, you want to listen to the actual physical interface, likely eth0 in your case for those requests.

You will then need to define the rules for leasing IP addresses to those groups - via static MAC address mapping, or whatever (I'm guessing ubuntu) will let you do.

The eth0:1 and eth0:0 interfaces are only necessary for NAT routing, and shouldn't appear anywhere in your DHCP config.