• CentOS开端口问题


    关闭SELINUX

    ##查看SELINUX状态
    /usr/sbin/sestatus -v      
    getenforce             
    
    #修改config配置文件,重启后即可
    vi /etc/selinux/config    #SELINUX=enforcing改为SELINUX=disabled
    
    #临时关闭(不用重启机器):
    setenforce 0      ##设置SELinux 成为permissive模式,
    ##setenforce 1 设置SELinux 即可成为enforcing模式

    CentOS7防火墙

    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    #查看是否拒绝
     
    #添加
    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 start firewalld    #启动
    systemctl status firewalld     #查看状态
    systemctl disable firewalld    #停止
    systemctl stop firewalld    #禁用
    systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。
    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    #查看启动失败的服务列表

    CentOS6

    修改文件/etc/sysconfig/iptables
    
        #su vi /etc/sysconfig/iptables 
        -A INPUT -p tcp -m tcp --dport 8066 -j ACCEPT
        # service iptables restart
    Linux下开启/关闭防火墙命令
        #1) 永久性生效,重启后不会复原
        #开启: chkconfig iptables on
        #关闭: chkconfig iptables off
    
        #2) 即时生效,重启后复原
        #开启: service iptables start
        #关闭: service iptables stop

    测试

    1.确定服务是否启动,端口是否正在被监听

    ps -ef|grep mycat

    2.netstat测试是否在被监听

    netstat -an|grep 8066

    打开端口

    关闭端口

    步骤:

    1. 安装好虚拟机配置好网络 ping 通主机。
    2. 关闭SELINUX。
      vi /etc/selinux/config    #SELINUX=enforcing改为SELINUX=disabled
      reboot    #重启
    3. 开防火墙端口,或者这接关闭(不建议)。
      注意:开了端口后一定要有服务监听(例如Tomcat一定要启动,否则是telnet不通的)!!!也就是说开了端口一定要起服务才能telnet通。
    4. telnet IP port。
  • 相关阅读:
    安装Flume的时候出现File Channel transaction capacity cannot be greater than the capacity of the channel capacity -解决方案 摘自网络
    在linux中配置环境变量
    CentOS中安装JAVA环境
    怎么在linux 用nginx做代理 配置.net core
    Another app is currently holding the yum lock; waiting for it to exit.. yum被锁定无法使用
    jQueryUI modal dialog does not show close button (x) JQueryUI和BootStrap混用时候,右上角关闭按钮显示不出图标的解决办法
    C#中 如何处理 JSON中的特殊字符
    php面向对象精要(3)
    php面向对象精要(2)
    php面向对象精要(1)
  • 原文地址:https://www.cnblogs.com/aeolian/p/8893545.html
Copyright © 2020-2023  润新知