方法一:CentOS 6
0.防火墙操作
即时生效,重启后失效:
开启防火墙
/etc/rc.d/init.d/iptables start
关闭防火墙
/etc/rc.d/init.d/iptables stop
重启后永久性生效:
开启防火墙
chkconfig iptables on
关闭防火墙
chkconfig iptables off
1.开放指定端口
开放端口
/sbin/iptables -I INPUT -p tcp –dport 端口 -j ACCEPT
保存配置
/etc/init.d/iptables save
重启防火墙
/etc/rc.d/init.d/iptables restart
2.关闭指定端口
关闭端口
/sbin/iptables -I INPUT -p tcp –dport 端口 -j DROP
保存配置
/etc/init.d/iptables save
重启防火墙
/etc/rc.d/init.d/iptables restart
3.查看端口状态
查看
/etc/init.d/iptables status
4.清除防火墙规则
清除
iptables -F
若上面方面报错,则证明你服务器系统是Centos7以上,则用以下方法
方法二:CentOS 7
0.防火墙操作
查看防火墙
systemctl status firewalld
即时生效,重启后失效:
开启防火墙
systemctl start firewalld
关闭防火墙
systemctl stop firewalld
重启后永久性生效:
开启防火墙
systemctl enable firewalld
关闭防火墙
systemctl disable firewalld
1.开放指定端口
开放端口
firewall-cmd –zone=public –add-port=端口/tcp –permanent
重新载入
firewall-cmd –reload
2.关闭指定端口
关闭端口
firewall-cmd –zone=public –remove-port=端口/tcp –permanent
重新载入
firewall-cmd –reload
3.查看端口状态
查看端口
firewall-cmd –zone=public –query-port=端口/tcp
4.查询开放端口列表
查看列表
firewall-cmd –zone=public –list-ports
若开放了端口还是连接不上你想要的端口,注意:有可能是你服务器自带安全组策略限制的原因,这种情况需要在官方服务器管理控制台手动开放。
1.所有资源均搜集自互联网,版权归原作者!仅供测试使用,如有侵权请联系我们!
2.分享目的仅供大家学习和交流,您必须在下载后24小时内删除!本站不承担任何法律责任!
3.不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 仅对资源整理优化,不对资源内容负责!不免费包含技术服务!
5.若资源链接失效,请联系发帖作者,添加群联系管理员或添加客服!

软壳源码网 » centos6,centos7开放防火墙指定端口两种方法

常见问题FAQ

签到位置不知道?
头像旁边右上角三横按钮-点击出现个人信息-签到(任意页面最右侧跟随浮动栏)
解压密码?
www.ruankor.com或者ruankor.com

260 评论

  1. order vardenafil 20mg pill generic medrol methylprednisolone 16 mg without prescription

  2. My colleague shared your article with me and I found it very useful after reading it. Great article, it helped me a lot. I also hope to make a beautiful website like your blog, hope you can give me some advice, my website:
    gate.io review

  3. order asacol 400mg generic buy avapro brand avapro 150mg

  4. A motivating discussion is worth comment. I do believe that you need to
    write more about this issue, it might not be a taboo
    subject but generally folks don’t talk about such issues.

    To the next! Best wishes!!

  5. order doxycycline 100mg pill levitra oral order acyclovir 400mg generic

  6. Wow that was strange. I just wrote an very long comment but after I clicked
    submit my comment didn’t show up. Grrrr… well I’m not
    writing all that over again. Regardless, just wanted to say
    superb blog!

  7. order ranitidine pill brand mobic order celebrex 100mg generic

  8. buy plavix 75mg without prescription fluvoxamine usa buy nizoral without a prescription

  9. I am an investor of gate io, I have consulted a lot of information, I hope to upgrade my investment strategy with a new model. Your article creation ideas have given me a lot of inspiration, but I still have some doubts. I wonder if you can help me? Thanks.

  10. buy diamox without a prescription imdur oral order azathioprine 25mg online

  11. If you want to grow your know-how only keep visiting this\r\nwebsite and be updated with the most up-to-date gossip posted here.\r\n\r\nFeel free to surf to my webpage: youtube to mp3

发表评论

提供最优质的资源集合

加入本群 联系客服
本站由免费云加速(FreeCDN)提供网站加速和攻击防御服务