Skip to content

Instantly share code, notes, and snippets.

@wsvn53
Last active March 16, 2016 13:03
Show Gist options
  • Save wsvn53/bb2f25dcb0fda8b8d964 to your computer and use it in GitHub Desktop.
Save wsvn53/bb2f25dcb0fda8b8d964 to your computer and use it in GitHub Desktop.
Auto enbale/disable ping request of gateway, for router check gateway avaliable.
/etc/vpnc/post-connect.d/enable-ping.sh
---------------------------------------
#!/bin/bash
echo "Connected.";
# enable host ping
while [ ! -z "$(iptables -L | grep icmp-net-unreachable)" ]; do
echo "==> delete icmp-net-unreachable";
iptables -D INPUT -p icmp -m icmp --icmp-type echo-request -j REJECT --reject-with icmp-net-unreachable;
done
echo "Ping enabled.";
/etc/vpnc/disconnect.d/disable-ping.sh
--------------------------------------
#!/bin/bash
echo "Disconnected.";
# disable host ping
[ -z "$(iptables -L | grep icmp-net-unreachable)" ] && {
iptables -A INPUT -p icmp -m icmp --icmp-type echo-request -j REJECT --reject-with icmp-net-unreachable;
}
echo "Ping disabled.";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment