0

I'm setting up a FreeBSD carp router/firewall backup, my provider is giving out IP by DHCP, it's static and tied to MAC address of my NIC, so when carp switches state I'm trying to switch off the interface on one machine and switch it on on another. It works. So good so far...

My problem is when I reboot BACKUP machine the interface is getting configured after reboot - it talks to the DHCP-server with a MAC which is used in the network already, and gets an answer. Not good at all - for a moment arp tables of my switches are directing packets to the wrong port.

I tried to:

  • start dhclient em0 on switching to the MASTER state and ifconfig_em0="down" in rc.conf, but if eventually interface goes to link down state the dhclient exits and doesn't resume as devd, which is supposed to resume it, checks with dhcpif from network.subr - and tells that "em0 is not dhcp-enabled interface".

  • set ifconfig_em0="down dhcp" and remove dhclient.leases.em0 file, then reboot - my interface is down and configured after startup(probably it even was up, and then disabled by my script when entered carp BACKUP state).

As far as I understand there's no way to set a NIC as DHCP-enabled, to have on-link-up dhclient started by devd, but keeping it totally silent during boot process?

1 Answers1

0

As a workaround I've added custom devd job to run dhclient without checks:

# cat /usr/local/etc/devd/dhclient.conf

 notify 1 {
    match "system"          "IFNET";
    match "type"            "LINK_UP";
    media-type              "ethernet";
    match "subsystem"   "em0";
    action "/usr/local/sbin/dhcp_linkup_carp.sh";
 };


# cat /usr/local/sbin/dhcp_linkup_carp.sh

 #!/bin/sh

 [ "`ifconfig em0 | grep inet`" ] && dhclient em0

and set ifconfig_em0="down" in the rc.conf (interface is getting up by devd carp scripts)