Skip to content

Instantly share code, notes, and snippets.

@p-rintz
Last active November 19, 2018 11:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save p-rintz/61ef9ed8e30da79d2166c5c8f28b3f90 to your computer and use it in GitHub Desktop.
Save p-rintz/61ef9ed8e30da79d2166c5c8f28b3f90 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