1.7 KiB
opnsense-carp-dhcp
I'm making a a very large assumation in that, the primary router comes online before the backup, if both are offline.
My setup is the master router is physical hardware while the backup is a VM on an encrypted vsan. So if everything is powered off, the physical should be the first to power on and can start this process. If we are just rebooting the master router, there is a check to see if the backup router is online and if so, this doesn't run.
These scripts will set the WAN to DHCP and grab the IP, subnet, and gateway from it. From there is will set the WAN back to a static private IP, setup the CARP VIP WAN to the DHCP IP/subnet, and setup the gateway. Then once the config is copied to the backup router, the script there will update the gateway with the new address from the CARP VIP WAN description if it is different.
Master Router
The opnsense-carp-dhcp-master.php should be saved to /usr/local/etc/rc.syshook.d/start/20-opnsense-carp-dhcp-master and made executable. Please replace the varaibles with your own values.
You can pass in the -f|--force option to force the script to run.
Backup Router
The opnsense-carp-dhcp-backup.php should be saved to /usr/local/etc/rc.syshook.d/config/20-opnsense-carp-dhcp-master and made executable. This will update the gateway IP after the config is updated. Please replace the varaibles with your own values.
Variables
$wanInterface: This should be the wan interface as default. It could also be another opt# interface name as well. $gatewayName: should be the name of the manual gateway used for the static WAN IP. $wanStaticIP: This should be the private IP address for the Static WAN Interface. $wanStaticIPSubnet: This should be the subnet bits for the Static WAN Interafce, ex. 30