Re: How to run script on network address change?

From: Eugene Grosbein <>
Date: Fri, 9 Jul 2021 05:00:41 +0700
20.06.2021 20:52, Rozhuk Ivan wrote
> Hi!
> I have FreeBSD 13_at_amd64 router with DHCP client on uplink.
> How to run script on IP address change?

Here is my /etc/dhclient-enter-hooks I use with FreeBSD 11 and stock dhclient
for a system with two distinct ISP uplinks. It replaces some of default hooks:


# Ignore ISP DNS servers as we run our own resolver
add_new_resolv_conf() {
  return 0

add_new_address() {
	# Perform interface configuration
        eval "$IFCONFIG $interface \
                inet $new_ip_address \
                netmask $new_subnet_mask \
                broadcast $new_broadcast_address \

	# Save ISP gateway address with interface description for easy access
        eval '$IFCONFIG $interface description "gw $new_routers"'

	# Generate nice logs
        $LOGGER "New IP Address ($interface): $new_ip_address"
        $LOGGER "New Subnet Mask ($interface): $new_subnet_mask"
        $LOGGER "New Broadcast Address ($interface): $new_broadcast_address"
        $LOGGER "New Routers ($interface): $new_routers"

	# Some additional logic may be added here like switching default route
        return 0
Received on Thu Jul 08 2021 - 22:00:41 UTC

Original text of this message