zoukankan      html  css  js  c++  java
  • 关于centOS 7的服务启动,端口查询,防火墙管理

    端口的查询与开启

    CentOS 7 默认没有使用iptables,所以通过编辑iptables的配置文件来开启80端口是不可以的
    CentOS 7 采用了 firewalld 防火墙

    如要查询是否开启80端口则:
    [root@www ~]# firewall-cmd --query-port=80/tcp
    no
    显然80端口没有开启

    下面我们开启80端口:

    [root@joe-pc ~]# firewall-cmd --add-port=80/tcp
    success

    [root@joe-pc ~]# ps aux | grep httpd
    root 7579 0.0 0.0 3872 656 pts/1 S+ 17:48 0:00 grep httpd
    apache 12229 0.0 0.3 32940 7108 ? S 04:03 0:00 /usr/sbin/httpd
    apache 12230 0.0 0.3 33076 7680 ? S 04:03 0:00 /usr/sbin/httpd
    apache 12231 0.0 0.3 33076 7820 ? S 04:03 0:00 /usr/sbin/httpd
    apache 12232 0.0 0.3 33076 7176 ? S 04:03 0:00 /usr/sbin/httpd

    [root@joe-pc ~]#netstat -anp | grep 80
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12229/httpd 
    tcp 0 0 xxx.xxx.xxx.xxx:48500 xxx.xxx.xxx.xxx:80 ESTABLISHED 1827/AliYunDun

    服务的开启,关闭,状态

    systemctl start httpd.service #启动

    systemctl stop httpd.service #停止

    systemctl restart httpd.service #重启

    第二、设置开机启动/关闭

    systemctl enable httpd.service #开机启动

    systemctl disable httpd.service #开机不启动

    第三、检查httpd状态

    systemctl status httpd.service

    关于centOS7.2的防火墙

    说明:Centos7 下默认的防火墙是 Firewall,替代了之前的 iptables,Firewall 有图形界面管理和命令行管理两种方式,本文简要介绍命令 行Firewall 的使用。

    进入系统之后,Centos7 默认是已安装了 Firewall,但是没有启动的,所以需要先启动下 Firewall,同时设置开机自启动

    systemctl start firewalld ##启动Firewall

    systemctl enable firewalld.service ##设置开机自启动

    ln -s '/usr/lib/systemd/system/firewalld.service' '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'
    ln -s '/usr/lib/systemd/system/firewalld.service' '/etc/systemd/system/basic.target.wants/firewalld.service'

    firewall-cmd --state ##查看防火墙状态,是否是running
    firewall-cmd --reload ##重新载入配置,比如添加规则之后,需要执行此命令
    firewall-cmd --get-zones ##列出支持的zone
    firewall-cmd --get-services ##列出支持的服务,在列表中的服务是放行的
    firewall-cmd --query-service ftp ##查看ftp服务是否支持,返回yes或者no
    firewall-cmd --add-service=ftp ##临时开放ftp服务
    firewall-cmd --add-service=ftp --permanent ##永久开放ftp服务
    firewall-cmd --remove-service=ftp --permanent ##永久移除ftp服务
    firewall-cmd --add-port=80/tcp --permanent ##永久添加80端口
    iptables -L -n ##查看规则,这个命令是和iptables的相同的
    man firewall-cmd ##查看帮助

  • 相关阅读:
    用Eclipse做J2Me开发的前期配置
    cglib和asm相关的文章
    bcp命令详解
    Oracle/PLSQL AFTER DELETE Trigger
    Mybatis(九)分页插件PageHelper使用
    Mybatis(八)逆向工程
    Mybatis(四)关联映射
    Mybatis(三)返回值四.注解配置
    Mybatis(二)参数(Parameters)传递
    Mybatis(一)实现单表的增删改查
  • 原文地址:https://www.cnblogs.com/duzhaoqi/p/6938347.html
Copyright © 2011-2022 走看看