4

Is it possible to use a single DHCP server to push completely different ranges of ip to different network interfaces in different LANs?

EXAMPLE:

I have the Severs #1 and #2.

Severs #1: A DHCP server with a network interface called "enpA" which is connected to LAN A.

Severs #2: A DHCP client with an network interface called "enpA" which is also connected to LAN A. It has a network interface called "enpB" which is connected to LAN B.

LAN A: 192.168.56.0/24

LAN B: 10.0.2.0/24

I wanted the LAN A server (Severs #1) push an ip to the "enpB" (Severs #2) interface which is connected to LAN B. That is, is it possible to do this with a single DHCP server connected in LAN A?

If yes what strategy should I use with a DHCP server like the isc KEA?

8

Yes, you can do this. What you need to do is run a DHCP relay agent on server B, which listens for DHCP requests on UDP/67 (UDP/547 for DHCPv6) on its LAN B interface and forwards them to LAN A (the DHCP server obviously needs to be set up to have network pools for both networks!)

The system works something like this:

Server 1        LAN A        Server 2         LAN B        Client
                                    *          <--        Request
       *         <--     Request (for Client)
  Answer         -->         *
                        Answer (from Server 1) -->        *
                               [...]

DHCPv4 and DHCPv6 relays are handled individually, so you will need two instances of the relay running if you want to handle both types.

Assuming Server A is 192.168.56.1/2001:db8:1::1, and Server B has eth0/192.168.56.2/2001:db8:1::2 on LAN A and eth1/10.0.2.1/2001:db8:2::1 on LAN B, you would run the relay like this:

  • DHCPv4: /path/to/dhcrelay -4 -i eth1 192.168.56.1
  • DHCPv6: /path/to/dhcrelay -6 -l eth1 -u eth0

Note that I haven't had a need to use DHCPv6 relays, so this is based on the documentation.

7

Whilst technically @ErikF's is the right answer to your question as it is asked, it makes much more sense to set up server #2 as a multi-homed DHCP server.

Doing that, you won't need to setup a DHCP relay, and the complexity is also drastically reduced.

  • 1
    That would be the easiest solution, as server #2 is the only device that can see both networks simultaneously. – Tonny Jul 31 '18 at 8:35
  • 1
    "Whilst technically @ErikF's is the right answer to your question as it is asked" -> Yes, you're right! ErikF did a great job and answered exactly my question, but according to some studies I did it would be better to use an approach like yours and trust in OSI's "Layer 2". ( Thanks "old" friends! =D ) – Eduardo Lucio Jul 31 '18 at 16:16
  • 1
    The only time that I ever actually used a DHCP relay was when I was working on getting my CCNA 20 years ago, so take from that what you will! I would also probably move the DHCP server to the multi-homed server if at all possible. – ErikF Jul 31 '18 at 16:48
  • @ErikF Yes for sure! Your insight and understanding of both solutions was perfect! Thanks! =D – Eduardo Lucio Jul 31 '18 at 16:59
1

Yes, it's completely possible. I do that on my own setup. There are 2 requirements/conditions:

  1. The DHCP server software you're using allows it (there is more than one software for DHCP, perhaps some don't; the "usual" ones do)
  2. Both subnets have firewall/routing rules that allow devices in those subnets to successfully query the DHCP server. That might require port mapping, routing rules, one-to-one or outbound NAT (on IPv4) or other methods.

In my case, I use dhcpd and the router has 2 network cards, one for each subnet. I set the IP for each subnet to "x.x.x.1". Then my dhcpd.conf is as follows.

I've simplified it, and modified it to use your IP addresses, otherwise it's unchanged. If you don't want your router to also be the DNS server/resolver, remove the four lines containing "option domain-name-servers":

option domain-name "mydomain.com";
option ldap-server code 95 = text;
option arch code 93 = unsigned integer 16; # RFC4578

default-lease-time 7200;
max-lease-time 86400;
one-lease-per-client true;
deny duplicates;
ping-check true;
update-conflict-detection false;
authoritative;

subnet 192.168.56.0 netmask 255.255.255.0 {
  pool {
    option domain-name-servers 192.168.56.1;
    range 192.168.56.2 192.168.56.254;
  }

  option routers 192.168.56.1;
  option domain-name-servers 192.168.56.1;
}

subnet 10.0.2.0 netmask 255.255.255.0 {
  pool {
    option domain-name-servers 10.0.2.1;
    range 10.0.2.2 10.0.2.254;
  }

  option routers 10.0.2.1;
  option domain-name-servers 10.0.2.1;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.