华域联盟 Linux linux防火墙关了 端口不通处理方法

linux防火墙关了 端口不通处理方法

重启后生效
开启: 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

本文由 华域联盟 原创撰写:华域联盟 » linux防火墙关了 端口不通处理方法

转载请保留出处和原文链接:https://www.cnhackhy.com/12197.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

每日 Ubuntu 小技巧——关闭 Ubuntu 中的关机/重启确认

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部