5

I'm setting up a Debian to work as a gateway for a small office network. I need to have three subnetworks for different areas within the company and I will define which PCs will get what IP based on their MAC addresses.

My question is: is it possible to handle DHCP for 3 subnets with a single NIC? how?

I tried setting up on virtual interface for each network like this:

# ip addr show dev eth2
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 6c:f0:49:a4:47:38 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global eth2
    inet 10.1.2.1/24 brd 10.1.2.255 scope global eth2:1
    inet 10.1.3.1/24 brd 10.1.3.255 scope global eth2:2
    inet 10.1.1.1/24 brd 10.1.1.255 scope global eth2:0
    inet6 fe80::6ef0:49ff:fea4:4738/64 scope link 
       valid_lft forever preferred_lft forever

Note: eth2 is using 192.168.1.10 because the box is not currently the network gateway. This is just temporary.

Then I set up my dhcpd.conf like this:

ddns-update-style interim;
option domain-name "mydomain.com";
option domain-name-servers ns1.mydomain.com;
default-lease-time 86400;
max-lease-time 86400;
authoritative;
log-facility local7;

subnet 10.1.1.0 netmask 255.255.255.0 {
        range 10.1.1.100 10.1.1.254;
        default-lease-time 86400;
        max-lease-time 86400;
        option routers 10.1.1.1;
        option ip-forwarding off;
        option broadcast-address 10.1.1.255;
        option subnet-mask 255.255.255.0;
        option ntp-servers 10.1.1.1;
        option domain-name-servers 10.1.1.1;
}

subnet 10.1.2.0 netmask 255.255.255.0 {
        range 10.1.2.100 10.1.2.254;
        default-lease-time 86400;
        max-lease-time 86400;
        option routers 10.1.2.1;
        option ip-forwarding off;
        option broadcast-address 10.1.2.255;
        option subnet-mask 255.255.255.0;
        option ntp-servers 10.1.2.1;
        option domain-name-servers 10.1.2.1;
}

subnet 10.1.3.0 netmask 255.255.255.0 {
        range 10.1.3.100 10.1.3.254;
        default-lease-time 86400;
        max-lease-time 86400;
        option routers 10.1.3.1;
        option ip-forwarding off;
        option broadcast-address 10.1.3.255;
        option subnet-mask 255.255.255.0;
        option ntp-servers 10.1.3.1;
        option domain-name-servers 10.1.3.1;
}

But when I try to launch dhcpd I get this:

# dhcpd -4 eth2:0 eth2:1 eth2:2
Internet Systems Consortium DHCP Server 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Wrote 0 leases to leases file.

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


No subnet declaration for eth2:1 (no IPv4 addresses).
** Ignoring requests on eth2: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 eth2:1 is attached. **


No subnet declaration for eth2:0 (no IPv4 addresses).
** Ignoring requests on eth2: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 eth2:0 is attached. **


Not configured to listen on any interfaces!

I'm really new to DHCP, so I'm probably missing something obvious. I've been googling for a while but I can't find the answers I need or I'm not searching right.

2 Answers 2

5

Since the three subnets share the same medium (eth2), they should be declared inside the same shared-network:

shared-network my-net {
  subnet 10.1.1.0 netmask 255.255.255.0 {
    ...
  }

  subnet 10.1.2.0 netmask 255.255.255.0 {
    ...
  }

  subnet 10.1.3.0 netmask 255.255.255.0 {
    ...
  }
}
3
  • Thanks, I added that (and edited my question), but I get the same error when I try to launch dhcpd.
    – El Barto
    May 18, 2012 at 15:09
  • Ok, try dhcpd -4 eth2.
    – Oliver
    May 18, 2012 at 15:09
  • 1
    Thanks! I got it working by adding an empty subnet for 192.168.1.0 and running dhcpd -4 eth2.
    – El Barto
    May 18, 2012 at 15:18
0

There's really only two ways to do this;

  1. Set your DHCP server's IP to be the 'DHCP Helper Address' on your L3 Switch for each VLAN then define the scopes for those on your server.
  2. Set the DHCP server's NIC port on the switch to be a .1q trunk carrying all appropriate VLANs then setup the separate vNICs on your server with appropriate IPs for each VLAN and go from there.

Either way try not to just use a single NIC, you should have two for resilience and then just bond them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .