Centos6.4下iptables防火墙配置

配置Cento6.4 iptables防火墙。


1. 查看防火墙状态

# service iptables status
或:

# /etc/init.d/iptables status
说明:下面也可以用此方法操作。


2.关闭 /开启/重启防火墙

# service iptables stop
# service iptables start
# service iptables restart

4.永久关闭防火墙

# chkconfig --level 35 iptables off

然后重启系统使其生效:

# shutdown -r now


5.设置开启80端口访问

>先查看防火墙状态:

[root@localhost nginx]# service iptables status

Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 


Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 


Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination  


>设置80端口(或者手动修改/etc/sysconfig/iptables)

[root@localhost ~]# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
You have new mail in /var/spool/mail/root

>保存设置

[root@localhost ~]# /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]


>再查看防火墙状态

[root@localhost ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80 
2    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
3    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
6    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 


Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 


Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

>设置80端口--修改/etc/sysconfig/iptables配置文件

[root@localhost ~]# vi /etc/sysconfig/iptables
# 添加下面内容
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
最后重启防火墙使配置生效。


-------------------------------------------------------------------------------------------------------------------------------------

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值