Created
October 21, 2015 15:35
-
-
Save LogIN-/4f5ff61d7d29e9d56a74 to your computer and use it in GitHub Desktop.
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 | |
| # Check new IPv4 addresses | |
| # If address is not in iptables add rule | |
| IPLISTV4=$(host maps.googleapis.com | grep -E 'has address' | awk '{print $4}') | |
| for x in $IPLISTV4 | |
| do | |
| $(iptables -L -nv | grep "$x" >> /dev/null) | |
| if [[ "$?" -ne '0' ]]; then | |
| $(iptables -I OUTPUT -p tcp -m tcp -d "$x" -m state --state NEW -j ACCEPT) | |
| fi | |
| done | |
| # Check new IPv6 addresses | |
| # If address is not in iptables add rule | |
| IPLISTV6=$(host maps.googleapis.com | grep -E 'has IPv6 address' | awk '{print $5}') | |
| for x in $IPLISTV6 | |
| do | |
| $(iptables -L -nv | grep "$x" >> /dev/null) | |
| if [[ "$?" -ne '0' ]]; then | |
| $(iptables -I OUTPUT -p tcp -m tcp -d "$x" -m state --state NEW -j ACCEPT) | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment