虽然工作跟此没关,但还是喜欢偶尔弄弄linux,水平肯定提高很慢,只为自娱自乐吧,哈哈。
- #!/bin/sh
-
# Variables declare
-
TRUSTIP="192.168.0.0/255.255.255.0"
-
IPTABLES="/sbin/iptables"
-
echo "Start iptables setup"
-
# Remove current rules
-
echo "Remove current rules"
-
$IPTABLES -F
-
$IPTABLES -X
-
$IPTABLES -Z
-
# Set default rules DROP
-
$IPTABLES -P INPUT DROP
-
$IPTABLES -P FORWARD DROP
-
$IPTABLES -P OUTPUT DROP
-
# Set up INPUT rules
-
echo "Set INPUT rules..."
-
# SSH
-
$IPTABLES -A INPUT -p tcp -s $TRUSTIP --dport 22 -j ACCEPT
-
$IPTABLES -A INPUT -p udp -s $TRUSTIP --dport 22 -j ACCEPT
-
# Set up OUTPUT rules
-
echo "Set OUTPUT rules..."
-
# SSH
-
$IPTABLES -A OUTPUT -p tcp --sport 22 -j ACCEPT
-
$IPTABLES -A OUTPUT -p udp --sport 22 -j ACCEPT
-
# Display result
-
echo "Iptables set up complete!"
-
$IPTABLES -L -n
阅读(679) | 评论(0) | 转发(0) |