2

In the following diagram, I have two routers between LAN A and B, and several hosts on LAN A that should have connectivity to LAN B. My goal is to have half my hosts using R1, and the other half using R2. To do that, I thought about using a DHCP giving a different gateway to 50% of my hosts.

enter image description here

Here is my DHCP conf:

default-lease-time 600;
max-lease-time 7200;

subnet 10.1.1.0 netmask 255.255.255.0 {
  range 10.1.1.3 10.1.1.254;
  option domain-name-servers 1.1.1.1;
  option routers 10.1.1.1;
}

How can I do that?

Fabby
  • 34,259
Nakrule
  • 163
  • I don't want that clients from LAN A use gateway A and clients from LAN B gateway B, but that 50% from LAN A use Gateway A, and the other half gateway B. – Nakrule Jun 18 '18 at 13:35
  • So what's your goal here? Trying to get all of the LAN A devices to go through one of two gateways dynamically? How do you intend to differentiate between which hosts go where? (You could theoretically do this with static DHCP reservations and rules, but it's non-trivial and fragile, and you can't do this dynamically if you intend this to be done with multiple hosts.) DHCP on its own can't dynamically decide which of two gateways to give to an individual group, it doesn't have that capability; you can desginate different hosts getting different options, but only if you do so manually. – Thomas Ward Jun 19 '18 at 16:11
  • If your intention is to have the DHCP server 'decide' which hosts get which gateway automatically, without you manually defining which hosts get which gateway by hand, then you can't achieve this because DHCP cannot do this. The only mechanism to do this is multiple subnets with different DHCP ranges. – Thomas Ward Jun 19 '18 at 16:16
  • 1
    @ThomasWard See below. Feasible but impractical. I think this is an XY problem – Fabby Jun 19 '18 at 16:23

1 Answers1

5

Yes you can do that by:

  • Defining 2 ranges on your DHCP server

    subnet 10.1.1.0 netmask 255.255.255.0 {
      range 10.1.1.3 10.1.1.254;
      option domain-name-servers 1.1.1.1;
      option routers 10.1.1.1;
    }
    subnet 10.1.2.0 netmask 255.255.255.0 {
      range 10.1.2.3 10.1.2.254;
      option domain-name-servers 1.1.2.1;
      option routers 10.1.2.1;
    }
    
  • Giving each host a reserved IP address:

    host Host1 {
       hardware ethernet 01:02:03:04:05:06;
       fixed-address 10.1.1.2;
    }
    host Host2 {
       hardware ethernet 01:02:03:04:05:07;
       fixed-address 10.1.2.2;
    }
    

however

You might as well use fixed IP addresses if they're hosts...

Fabby
  • 34,259