最近一直在忙着为公司安装Linux服务器所以也学到了不少知识,下面就分享一下防火墙配置的一个sh脚本:
#!/bin/bash
# Stop iptables service first
service iptables stop
# Load FTP Kernel modules
#/sbin/modprobe ip_conntrack_ftp
#/sbin/modprobe ip_nat_ftp
# Inital chains default policy
/sbin/iptables -F -t filter
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT
# Enable Native Network Transfer
/sbin/iptables -A INPUT -i lo -j ACCEPT
# Accept Established Connections
/sbin/iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
# ICMP Control
#/sbin/iptables -A INPUT -p icmp -m limit –limit 1/s –limit-burst 10 -j ACCEPT
/sbin/iptables -A INPUT -p icmp -j ACCEPT
#drop IP
#iptables -I INPUT -s ***.***.***.*** -j DROP
# WWW Service
/sbin/iptables -A INPUT -p tcp –dport 80 -j ACCEPT
# SSH Service
/sbin/iptables -A INPUT -p tcp –dport 22 -j ACCEPT
# MySQL
/sbin/iptables -A INPUT -s 10.10.10.0/24 -p tcp –dport 3306 -j ACCEPT