Skip to content

Instantly share code, notes, and snippets.

@glidenote
Created December 27, 2011 17:41
Show Gist options
  • Save glidenote/1524517 to your computer and use it in GitHub Desktop.
Save glidenote/1524517 to your computer and use it in GitHub Desktop.
allow_ip.sh
#!/bin/sh
ALLOW_IP=`host hogehoge.com | awk '{print $4}'`
PORT_LIST="
22
80
443
3000
4000
4949
9821
"
# condrestartで設定をリセット
/etc/rc.d/init.d/iptables condrestart
for port in ${PORT_LIST}
do
echo "/sbin/iptables -I RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp -s ${ALLOW_IP} --dport ${port} -j ACCEPT"
/sbin/iptables -I RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp -s ${ALLOW_IP} --dport ${port} -j ACCEPT
done
/sbin/iptables -L -n
sshd: /etc/hosts.allow.d/my_home_ip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment