Skip to content

Instantly share code, notes, and snippets.

@hetrixtools
Forked from p-rintz/hetrix-update.sh
Created November 19, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hetrixtools/3f9bb85e3e43c0ec5ea5df573530ccdd to your computer and use it in GitHub Desktop.
Save hetrixtools/3f9bb85e3e43c0ec5ea5df573530ccdd to your computer and use it in GitHub Desktop.
Update/Install Hetrixtools iptables ping rules
#!/bin/bash
if [ -z "$1" ]; then
echo
echo "Please pass either 'install' or 'update' as parameter"
echo
elif [ $1 = "update" ]; then
echo "---------------------"
echo "Updating hetrix rules"
echo "---------------------"
wget https://hetrixtools.com/resources/uptime-monitor-ips.txt
iptables -F hetrix
cat uptime-monitor-ips.txt | sed 's/\s.*$//' | sed 's/com/com -j ACCEPT/g' | xargs -t -l1 iptables -A hetrix -s
rm uptime-monitor-ips.txt
echo
echo "All done"
elif [ $1 = "install" ]; then
echo "--------------------------------------------"
echo "Installing a new Hetrix chain and filling it"
echo "--------------------------------------------"
iptables -N hetrix
wget https://hetrixtools.com/resources/uptime-monitor-ips.txt
cat uptime-monitor-ips.txt | sed 's/\s.*$//' | sed 's/com/com -j ACCEPT/g' | xargs -t -l1 iptables -A hetrix -s
rm uptime-monitor-ips.txt
iptables -I INPUT -p icmp -m icmp --icmp-type any -m state --state NEW -j hetrix
echo
echo "All done"
else
echo "Wrong parameter set"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment