Re: How to run script on network address change?
- In reply to: Rozhuk Ivan : "How to run script on network address change?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 08 Jul 2021 22:00:41 UTC
20.06.2021 20:52, Rozhuk Ivan wrote > Hi! > > > I have FreeBSD 13@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: #!/bin/sh # 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 \ $medium" # 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 } # EOF