Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Created March 30, 2020 07:35
Show Gist options
  • Save alexalouit/17b6163067b4b59362518fddae73ddfc to your computer and use it in GitHub Desktop.
Save alexalouit/17b6163067b4b59362518fddae73ddfc to your computer and use it in GitHub Desktop.
proxmox firewall ip sync
#!/bin/bash
ip=`dig +short domain.tld`
if [ ! -f /tmp/.ip-sync ]; then
logger "ip-sync: create ip rule to $ip"
pvesh create /cluster/firewall/ipset/net --cidr $ip
echo $ip > /tmp/.ip-sync
else
if [ `cat /tmp/.ip-sync` != $ip ]; then
logger "ip-sync: update ip rule to $ip"
oldip=`cat /tmp/.ip-sync`
pvesh delete /cluster/firewall/ipset/net/$oldip
pvesh create /cluster/firewall/ipset/net --cidr $ip
echo $ip > /tmp/.ip-sync
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment