Centos 7防火墙firewalld开放80端口(转)
CentOS 7 为firewalld添加开放端口及相关资料
1、运行、停止、禁用firewalld
启动:# systemctl start firewalld
查看状态:# systemctl status firewalld 或者 firewall-cmd --state
停止:# systemctl disable firewalld
禁用:# systemctl stop firewalld
查看firewall是否运行,下面两个命令都可以
systemctl status firewalld.service firewall-cmd --state
查看default zone和active zone
我们还没有做任何配置,default zone和active zone都应该是public
firewall-cmd --get-default-zone firewall-cmd --get-active-zones
查看当前开了哪些端口
其实一个服务对应一个端口,每个服务对应/usr/lib/firewalld/services下面一个xml文件。
firewall-cmd --list-services
查看还有哪些服务可以打开
firewall-cmd --get-services
查看所有打开的端口:
firewall-cmd --zone=public --list-ports
更新防火墙规则:
firewall-cmd --reload
添加一个服务到firewalld
firewall-cmd --add-service=http //http换成想要开放的service
这样添加的service当前立刻生效,但系统下次启动就失效,可以测试使用。要永久开发一个service,加上 --permanent
firewall-cmd --permanent --add-service=http
如果要添加的端口并没有服务对应
就要新建一个服务,在/usr/lib/firewalld/services,随便拷贝一个xml文件到一个新名字,比如myservice.xml,把里面的
<?xml version="1.0" encoding="utf-8"?> <service> <short>Transmission-client</short> <description>Transmission is a lightweight GTK+ BitTorrent client.</description> <port protocol="tcp" port="51413"/> </service>
short改为想要名字(这个名字只是为了人来阅读,没有实际影响。重要的是修改 protocol和port。修改完保存。我的经验是这是要重启firewalld服务,systemctl restart firewalld.service
,否则可能提示找不到刚才新建的service。然后把新建的service添加到
firewalld
firewall-cmd --permanent --add-service=myservice
重启firewalld 生效
5分钟理解Centos7防火墙firewalld http://www.cnblogs.com/stevenzeng/p/5152324.html
-------------------------------------------------------------------------------------------------------------
启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed
3.配置firewalld-cmd
相关文章
- CentOS 9 开局配置
- Centos查看系统版本「建议收藏」
- centos部署ftp服务_文件服务器搭建
- dracut 查看linux分区,Centos进入dracut模式,报 /dev/centos/swap does not exist,如何恢复[通俗易懂]
- CentOS安装SQL Server
- Centos 7 安装 OpenJDK 11 yum 方式
- Centos 运维之防火墙篇——②firewalld
- Linux CentOS 7源码编译安装PostgreSQL9.5
- CentOS系统中Redis数据库的安装配置指南
- CentOS 下 Redis 2.2 安装配置详解程序员
- centos 6.x 设置默认的 python 2.6 为 python 2.7详解程序员
- CentOS 7.X 防火墙简单配置详解程序员
- CentOS 6.5下安装Python+Django+Nginx+uWSGI详解编程语言
- 在 CentOS 上安装 Redis,轻松搞定!(centos安装redis)
- 的关系Centos与Linux的同一路——开放的未来(centos与linux)
- 【CentOS】重启MySQL:一步一步教程(centos重启mysql)
- Centos修改swap虚拟内存大小方法
- CentOS上MySQL环境搭建指南(mysql centos)
- CentOS下搭建MySQL环境小贴士(centos下mysql)