您的位置:首页 > 运维架构 > Linux

Centos7 进程管理 - 防火墙

2019-04-25 23:46 225 查看

1、特殊说明

  • 在CentOS 7中改用了

    systemctl
    服务器命令,实际上是由 service(即时生效,重启后失效) 和 chkconfig(当前不生效,重启生效) 组成。详见下图 (序号表示不同实现方式)

    任务 CentOS7之前 CentOS7
    用于启动服务 service frobozz start systemctl start frobozz
    用于停止服务 service frobozz stop systemctl stop frobozz
    用于重新启动服务 service frobozz restart systemctl restart frobozz
    在不中断挂起操作的情况下重新加载配置文件。 service frobozz reload systemctl reload frobozz
    如果服务已经在运行,则重新启动。 service frobozz condrestart systemctl condrestart frobozz
    服务当前状态。 service frobozz status systemctl status frobozz
    用于列出可以启动或停止的服务。用于列出所有服务和其他单位 ls /etc/rc.d/init.d/ ① systemctl ② systemctl list-unit-files --type=service
    打开服务,以便在下一次启动时启动,或启动其他触发器。 chkconfig frobozz on systemctl enable frobozz
    为下一次重新启动或任何其他触发器关闭服务。 chkconfig frobozz off systemctl disable frobozz
    用于检查服务是否配置为在当前环境中启动。 chkconfig frobozz systemctl is-enabled frobozz
    打印一个服务表,该表列出每个运行级别上或关闭配置的运行级别。 chkconfig --list ① systemctl list-unit-files --type=service ② ls /etc/systemd/system/*.wants/
    打印在启动到图形模式时将启动的服务表。 chkconfig --list | grep 5:on systemctl list-dependencies graphical.target
    用于列出此服务在或关闭时配置的级别。 chkconfig frobozz --list ls /etc/systemd/system/*.wants/frobozz.service
    在创建新服务文件或修改任何配置时使用。 chkconfig frobozz --add systemctl daemon-reload

2、防火墙服务 (这里使用CentOS 7.0)

  1. 查看防火墙当前状态
  2. 关闭防火墙
  3. 重启防火墙
  4. 查看防火墙开放端口号
  5. 开启端口 ( 开启端口号后必须重新载入,命令:
    firewall-cmd --reload
    )

    命令含义:
    --zone //作用域
  6. --add-port=80/tcp //添加端口,格式为:端口/通讯协议
  7. --permanent //永久生效,没有此参数重启后失效
  • 删除端口 ( 删除后同样需要重新载入 )
  • 3、运行级别

    init级别 描述 systemctl target
    0 系统停机状态,系统默认运行级别不能设为0,否则不能正常启动 shutdown.target
    1 单用户工作状态,root权限,用于系统维护,禁止远程登陆 emergency.target
    2 多用户状态(没有NFS),不支持网络 rescure.target
    3 多用户状态(有NFS),登陆后进入命令行模式 multi-user.target
    4 系统未使用,保留
    5 图形界面 graphical.target
    6 系统正常关闭并重新启动,默认运行级别不能设为6,否则不能正常启动

    4、其他常用指令

    1. 查看服务
    2. 开启服务 (重启生效)
    3. 查看在启动到图形模式时将启动的服务表
    内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
    标签: