1. 使用setup命令
[1] 打开一个终端窗口,输入setup命令 [root@localhost ~]# setup
[2] 选择Firewall configuration, 选择Run Tool,进入防火墙配置界面
[3] 勾选Enabled开启防火墙,不勾选则不开启,此处开启,并选择Customize进行自定义配置
[4] 选择要开放的服务端口,此例选择FTP,WWW(HTTP)。默认SSH服务端口是开启的,用于SSH远程登陆,如果是远程配置Linux服务器,则一定要保持SSH服务端口打开,不要自断后路。
2. 命令行方式
[1] 编辑防火墙配置,21端口和80端口是增加的FTP服务与80服务端口 [root@localhost ~]# vi /etc/sysconfig/iptables # 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 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
[root@localhost ~]# service iptables stop
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
[root@localhost ~]# chkconfig iptables off (责任编辑:IT) |