linux防火墙关了端口还是不通,为什么linux防火墙关了 端口不通

用户:1046057485

2017年09月27日

) 重启后生效

开启: chkconfig iptables on

关闭: chkconfig iptables off

2) 即时生效,重启后失效

开启: service iptables start

关闭: service iptables stop

查看iptables文件

vim /etc/sysconfig/iptables

redhat部分-----------

1:端口开放

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

2:保存修改

/etc/rc.d/init.d/iptables save

3: 重启服务

/etc/rc.d/init.d/iptables restart

4:查看端口状态

/etc/init.d/iptables status

结果如下

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:2181

2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6379

3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080

4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED

5 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0

6 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0

7 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22

8 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

5:删除端口(2表示上面的num列)

/sbin/iptables -D INPUT 2

centos7部分-----------

开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent

--zone #作用域

--add-port=80/tcp #添加端口,格式为:端口/通讯协议

--permanent #永久生效,没有此参数重启后失效

重新加载防火墙

firewall-cmd --reload

检查修改是否生效

firewall-cmd --zone= public --query-port=80/tcp

删除某端口

firewall-cmd --zone= public --remove-port=80/tcp

firewall-cmd --zone=public --remove-service=http

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值