编辑防火墙配置文件:
vi /etc/sysconfig/iptables
防火墙启动:
service iptables restart
如果提示不存在配置文件,那就手动添加一个。
主要配置如下:
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10060:10090 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
开通了21、22端口,如果要开通80端口,插入如下语句即可:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
禁用某个端口,如8080:
-A INPUT -p tcp --dport 8080 -j DROP
比较简略,以后有空详细的研究一下。