centos 防火墙配置

1. 使用setup命令服务器

[1] 打开一个终端窗口,输入setup命令tcp

[root@localhost ~]# setup

[2] 选择Firewall configuration, 选择Run Tool,进入防火墙配置界面this

image

[3] 勾选Enabled开启防火墙,不勾选则不开启,此处开启,并选择Customize进行自定义配置spa

image

[4] 选择要开放的服务端口,此例选择FTP,WWW(HTTP)。默认SSH服务端口是开启的,用于SSH远程登录,若是是远程配置Linux服务器,则必定要保持SSH服务端口打开,不要自断后路。命令行

image

[5] 配置好后一路Forward到最后保存便可,若还有其它的端口要开放,中间也有相应的自定义页面。最后到这个页面时选择Yes,覆盖原设置保存。code

image

 

 

2. 命令行方式blog

[1] 编辑防火墙配置,21端口和80端口是增长的FTP服务与80服务端口ip

复制代码

[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

复制代码

[2] 关闭防火墙服务(暂时关闭防火墙服务,重启后服务会自动开启)get

[root@localhost ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]

[3] 配置防火墙服务默认开机不启动 (若是服务器不须要防火墙)it

[root@localhost ~]# chkconfig iptables off
相关文章
相关标签/搜索