Last active
September 22, 2025 22:24
-
-
Save Markieta/f2d6d677500603296d03168d57b49f5b to your computer and use it in GitHub Desktop.
Dynamically update Google IP set for firewall4 (nftables) in OpenWrt.
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
| #!/usr/bin/env ash | |
| FILE4=/tmp/google-ipv4 | |
| FILE6=/tmp/google-ipv6 | |
| GOOG=$(curl -s https://www.gstatic.com/ipranges/goog.json) | |
| IPV4=$(echo "$GOOG" | jq ".prefixes.[].ipv4Prefix | select( . != null )" -r) | |
| IPV6=$(echo "$GOOG" | jq ".prefixes.[].ipv6Prefix | select( . != null )" -r) | |
| reload=false | |
| if ! diff $FILE4 <(echo "$IPV4") > /dev/null; then | |
| echo "$IPV4" > $FILE4 | |
| reload=true | |
| fi | |
| if ! diff $FILE6 <(echo "$IPV6") > /dev/null; then | |
| echo "$IPV6" > $FILE6 | |
| reload=true | |
| fi | |
| if [ "$reload" = true ]; then | |
| fw4 -q reload-sets | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe need to replace
fw4 -q reload-setswithservice firewall restart