Created
March 30, 2020 07:35
-
-
Save alexalouit/17b6163067b4b59362518fddae73ddfc to your computer and use it in GitHub Desktop.
proxmox firewall ip sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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