Skip to content

Instantly share code, notes, and snippets.

@tubaman
Last active June 23, 2021 21:44
Show Gist options
  • Save tubaman/6925ffd01197e3880e2298cf64fd9179 to your computer and use it in GitHub Desktop.
Save tubaman/6925ffd01197e3880e2298cf64fd9179 to your computer and use it in GitHub Desktop.
dhcpcd hook to restart shorewall whenever the IP address changes (put in /lib/dhcpcd/dhcpcd-hooks)
if [ "$interface" = eth1 ]; then
if [ "$if_up" = true ]; then
IP=`ip add show eth1|grep global |awk '{print $2}'`
PREVIOUS_IP=`cat /tmp/previous_ip`
if [ "$PREVIOUS_IP" != "$IP" ]; then
echo "$IP" > /tmp/previous_ip
systemctl restart shorewall.service
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment