OPNsense Forum

Archive => 21.1 Legacy Series => Topic started by: puldi on May 21, 2021, 03:41:07 pm

Title: Assigning static routes with DHCPv4
Post by: puldi on May 21, 2021, 03:41:07 pm
Hi there,

we are currently preparing a migration of our servers from old cluster to new cluster. All settings will be left untouched so we are having the sam LAN on both clusters. The connection between the clusters is done via another network:

Code: [Select]
  .---------------.                    .---------------.
  |   Cluster A   |                    |   Cluster B   |
  | 172.22.0.0/16 |                    | 172.22.0.0/16 |
  '-------.-------'                    '-------.-------'
          |                                    |
          |                                    |
   .------'-------.                    .-------'------.
   |  Gateway A   |   172.23.1.0/24    |  Gateway B   |
   | 172.22.4.240 |--------------------| 172.22.4.250 |
   | 172.23.1.240 |                    | 172.23.1.250 |
   '--------------'                    '--------------'

Now I want to do the following: For each Host that is migrated to the new cluster I want to spread a static route in the old cluster to all hosts. This static route will route all traffic to that migrated host via a dedicated gateway.
The result should look like this:
Quote
default via 172.22.0.152 dev ens18 proto dhcp src 172.22.240.60 metric 100
172.22.0.0/16 dev ens18 proto kernel scope link src 172.22.240.60
172.22.0.0/16 via 172.22.4.250 dev ens18 proto dhcp src 172.22.240.60 metric 100
172.22.0.152 dev ens18 proto dhcp scope link src 172.22.240.60 metric 100
172.22.10.205 via 172.22.4.250 dev ens18

For spreading static routes the DHCP standard implements option 33 where I can concatenate pairs of destination and gateway. (THX to BertM for his HowTo on classless static routing (https://forum.opnsense.org/index.php?topic=1972.msg6117#msg6117))

BUT:

When adding some pairs in DHCPv4 -> Additional Options as number 33 of type string, the receiving host (dhclient) will take one of the entries as default gateway and all other static routes are lost:

Quote
default via 172.22.0.150 dev ens18
172.22.0.0/16 dev ens18 proto kernel scope link src 172.22.240.60

The host 172.22.0.150 is the standard gateway for some hosts on the other cluster. I know, I could just assign an additional IP to the gateway 172.22.0.152, so it will reply to packets, but I also need to reach the real 0.152 as there are also VPN tunnels. And after all, there are no more static routes assigned to the host even there are many of them defined.

The entry for option 33 is this:
Code: [Select]
AC:16:00:64:AC:16:04:FA:AC:16:00:96:AC:16:04:FA:AC:16:00:97:AC:16:04:FA:AC:16:04:F0:AC:16:04:FA:AC:16:0A:CD:AC:16:04:FA:AC:16:0B:0A:AC:16:04:FA:AC:16:0B:0B:AC:16:04:FA:AC:16:0B:0C:AC:16:04:FA:AC:16:0B:0D:AC:16:04:FA
In human readable form this is the list of ip adresses, each followed by 172.22.4.250 as gateway:
Quote
172.22.0.100
172.22.0.150
172.22.0.151
172.22.2.70
172.22.4.240
172.22.10.205
172.22.11.10
172.22.11.11
172.22.11.12
172.22.11.13

Can anyone point me to the failure I've made? I need to do this or similar setting on both clusters as traffic has be routed between them in both directions until the migration is done.
Title: Re: Assigning static routes with DHCPv4
Post by: astuckey on May 24, 2021, 05:09:31 pm
(sorry if it is obvious) - do your clients support option 33?
Title: Re: Assigning static routes with DHCPv4
Post by: puldi on May 25, 2021, 07:28:17 am
(sorry if it is obvious) - do your clients support option 33?
Is it optional? In fact, I really didn't think about that.  :-\
I will have a look.