We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在 centos7 时代防火墙已由 iptable 转向 firewalld,既然本文讲的是 centos7,那么我们就直接接受并适应它。:smile: 在此之前,要提一提systemctl:
systemctl
systemd 是一个 Linux 系统基础组件的集合,提供了一个系统和服务管理器,运行为 PID 1 并负责启动其它程序。功能包括:支持并行化任务;同时采用 socket 式与 D-Bus 总线式激活服务;按需启动守护进程(daemon);利用 Linux 的 cgroups 监视进程;支持快照和系统恢复;维护挂载点和自动挂载点;各服务间基于依赖关系进行精密控制。systemd 支持 SysV 和 LSB 初始脚本,可以替代 sysvinit。除此之外,功能还包括日志进程、控制基础系统配置,维护登陆用户列表以及系统账户、运行时目录和设置,可以运行容器和虚拟机,可以简单的管理网络配置、网络时间同步、日志转发和名称解析等。
简单说就是:systemctl 是 CentOS7 的服务管理工具中主要的工具,它融合之前 service 和 chkconfig 的功能于一体。在系统服务管理中推荐使用 systemctl 来管理。
下面以 firewalld 服务为例:
启动一个服务: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
2.配置 firewalld-cmd
查看版本: firewall-cmd --version 查看帮助: firewall-cmd --help 显示状态: firewall-cmd --state 查看所有打开的端口: firewall-cmd --zone=public --list-ports 更新防火墙规则: firewall-cmd --reload 查看区域信息: firewall-cmd --get-active-zones 查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0 拒绝所有包:firewall-cmd --panic-on 取消拒绝状态: firewall-cmd --panic-off 查看是否拒绝: firewall-cmd --query-panic
3.端口管理:
添加: firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent 永久生效,没有此参数重启后失效) 重新载入:firewall-cmd --reload 查看:firewall-cmd --zone= public --query-port=80/tcp 删除:firewall-cmd --zone= public --remove-port=80/tcp --permanent
正式环境下,看需要选择是否使用防火墙,这里为了方便后续配置,就先将其关闭:
关闭防火墙 systemctl stop firewalld 禁止开机自启systemctl disable firewalld 查看防火墙状态systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在 centos7 时代防火墙已由 iptable 转向 firewalld,既然本文讲的是 centos7,那么我们就直接接受并适应它。:smile:
在此之前,要提一提
systemctl
:简单说就是:systemctl 是 CentOS7 的服务管理工具中主要的工具,它融合之前 service 和 chkconfig 的功能于一体。在系统服务管理中推荐使用 systemctl 来管理。
下面以 firewalld 服务为例:
2.配置 firewalld-cmd
3.端口管理:
正式环境下,看需要选择是否使用防火墙,这里为了方便后续配置,就先将其关闭:
关闭防火墙
systemctl stop firewalld
禁止开机自启
systemctl disable firewalld
查看防火墙状态
systemctl status firewalld
The text was updated successfully, but these errors were encountered: