欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

centos7 以上和以下版本设置

发布时间:2025/4/5 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 centos7 以上和以下版本设置 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

centos 7以上版本防火墙设置
防火墙打版本
1.查看已开放的端口(默认不开放任何端口)
firewall-cmd --list-ports
2.开启80端口
firewall-cmd --zone=public(作用域) --add-port=80/tcp(端口和访问类型) --permanent(永久生效)
3.重启防火墙
firewall-cmd --reload
4.停止防火墙
systemctl stop firewalld.service
5.禁止防火墙开机启动
systemctl disable firewalld.service
6.删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent
7、增加端口
firewall-cmd --zone=public --add-port=80/tcp --permanent

centos7以下版本防火墙设置
1.开放80,22,8080 端口
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
2.保存
/etc/rc.d/init.d/iptables save
3.查看打开的端口
/etc/init.d/iptables status
4.关闭防火墙
1) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop

转载于:https://blog.51cto.com/guoshaoliang789/2114119

总结

以上是生活随笔为你收集整理的centos7 以上和以下版本设置的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。