1

I've got an ISC DHCP server 4.2.2 (Debian Wheezy) working. I need to add a second scope for unknown clients that gives them a bogus address (mostly for troubleshooting purposes). However, nothing I try seems to work. Truncated dhcpd4.conf file below with the new subnet declaration below.

subnet 10.111.111.0 netmask 255.255.255.0 {
        range 10.111.111.5 10.111.111.250;
        allow unknown-clients;
}

subnet 192.168.XXX.0 netmask 255.255.255.0 {
  range 192.168.XXX.194 192.168.XXX.200;
  range 192.168.XXX.100 192.168.XXX.109;
  range 192.168.XXX.215 192.168.XXX.250;

        ignore unknown-clients;
  option routers 192.168.XXX.XXX;
<lots more options>
}

I know that the DHCP server will ignore the 10.111.111.0 subnet if it has no interface with an IP on that subnet, so I first tried a virtual one. In /etc/network/interfaces, I added:

up ip addr add 10.111.111.1/24 dev eth0 label eth0:1

Then brought the interface up. ifconfig confirmed it was up. Then I added eth0:1 to /etc/default/isc-dhcp-server :

INTERFACES="eth0 eth0:1"

I then restarted the DHCP server, but got only the following:

...WARNING: Host declarations are global.  They are not limited to the scope you declared them in.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 53 leases to leases file.
Listening on LPF/eth0/00:50:XX:XX:XX:71/192.168.220.0/24
Sending on   LPF/eth0/00:50:XX:XX:XX:71/192.168.220.0/24
Sending on   Socket/fallback/fallback-net

Listening on 192.168.220.0, but not listening on 10.111.111.0. I then tried a more explicit command line:

/usr/sbin/dhcpd -cf /etc/dhcp/dhcpd4.conf eth0:1

But that only got me a

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. **

Searching around the Internet, I found a thread (Aliased network interfaces and isc dhcp server), and Zoredache's answer led me to try it without the virtual interface. I've got it set up and ip addr show shows the interface is there (but ifconfig does not - should I be concerned?).

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:50:XX:XX:XX:71 brd ff:ff:ff:ff:ff:ff
    inet 192.168.XXX.XXX/24 brd 192.168.220.255 scope global eth0
    inet 10.111.111.1/24 scope global eth0
    inet 192.168.XXX.XXX/24 scope global secondary eth0:0  

However, upon restarting the DHCP server, I don't get a listening on 10.111.111.1 message, just listening on 192.168.XXX.XXX.

Any ideas what I am doing wrong?

user2891127
  • 181
  • 2
  • 12
  • 1
    Have you tried with two separated configuration files and two separated dhcpd invocations? – Matías Apr 20 '15 at 16:59
  • Not yet. Everything I've read says you can have multiple subnets (IPv4) in the same config. – user2891127 Apr 20 '15 at 17:10
  • Minor but important: instead of `eth0:1` use multiple ip addresses of the same interface (`ip addr add … dev eth0`). It is the future, and in your case, it will make everything much more clear. – peterh Apr 20 '15 at 17:11
  • Yes it is possible, but since you have to listen on different interfaces, I haven't seeing this option on the man page. – Matías Apr 20 '15 at 17:11
  • To peterh, I did try the multiple ip addresses on the same interface. See the last code block. No change. – user2891127 Apr 20 '15 at 17:13
  • To Matias: Tried separate configs. "not configured to listen on any interfaces" for the 10.111.111.0 config file. – user2891127 Apr 20 '15 at 17:20
  • I remember, I also found this problem, but it was many years before, and can't remember the details. But finally I solved it. So, there _is_ a solution, don't give it up. – peterh Apr 20 '15 at 17:30

1 Answers1

6

OK, I figured it out. If you have more than one IP address assigned to the same interface, then all the subnet declarations have to be grouped together into another declaration. For example, the Linux machine has 192.168.1.1 and 10.10.10.1 (both /24) IP's on eth0. Then a simple scope would be:

shared-network mynet {
  subnet 10.10.10.0 netmask 255.255.255.0 {
      range 10.10.10.5 10.10.10.250;
      allow unknown-clients;
  }

  subnet 192.168.1.0 netmask 255.255.255.0 {
     range 192.168.1.194 192.168.1.200;
     ignore unknown-clients;
  }
}

The shared-network {} has to be around both subnet declarations. Then when you start the dhcp server, it will say listening on mynet rather than an ip address.

user2891127
  • 181
  • 2
  • 12