• centos7防火墙使用方法 风行天下


    参考网站:https://blog.csdn.net/achang21/article/details/52538049

    https://blog.csdn.net/weixin_45649763/article/details/103348513     (防火墙iptables与firewall-cmd区别)

    https://www.cnblogs.com/mozq/p/11159662.html

    添加开放指定端口:

    [root@yao bin]# firewall-cmd --zone=public --permanent --add-port=10051/tcp    

        命令含义:
    --zone #作用域
    --add-port=80/tcp #添加端口,格式为:端口/通讯协议
    --permanent #永久生效,没有此参数重启后失效

    添加多个不连续端口:

    [root@instance-fjii60o3 ~]# firewall-cmd --add-port=80/tcp --add-port=8080/tcp

    防火墙重启:

    [root@yao bin]# firewall-cmd --reload

    systemctl stop firewalld.service             #停止firewall
    systemctl disable firewalld.service        #禁止firewall开机启动

    查看防火墙列表:

    [root@yao bin]# firewall-cmd --list-all

     删除制定端口:

    firewall-cmd --zone= public --remove-port=80/tcp --permanent
    配置文件:

    [root@LinuxS03 ~]# vim /etc/firewalld/zones/public.xml 

    [root@yao ~]# cat /etc/firewalld/zones/public.xml
    <?xml version="1.0" encoding="utf-8"?>
    <zone>
    <short>Public</short>
    <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
    <service name="dhcpv6-client"/>
    <service name="ssh"/>
    <port protocol="tcp" port="22222"/>
    <port protocol="tcp" port="10050"/>
    <port protocol="tcp" port="10051"/>
    </zone>

    #######################################################################
    centos6防火墙开启方法:
    查看状态:
    iptables -L -n
    下面添加对特定端口开放的方法:
    使用iptables开放如下端口
    /sbin/iptables -I INPUT -p tcp --dport 8000 -j ACCEPT
    保存
    /etc/rc.d/init.d/iptables save
    重启服务
    service iptables restart
    查看需要打开的端口是否生效?
    /etc/init.d/iptables status

    法2:
    或直接编辑/etc/sysconfig/iptables
    -A INPUT -p tcp -m tcp --dport 4000 -j ACCEPT
    保存在前面部分
    再重启:
    service iptables restart
     
     
  • 相关阅读:
    如何得到需要下载文件的链接(路径)?
    Python之内存泄漏和内存溢出
    IO多路复用
    python-socket和进程线程协程(代码展示)
    Xshell(远程)连接不上linux服务器(防火墙介绍)
    Shell--变量
    Python读写配置文件模块--Configobj
    python文件处理之fileinput
    python之commands和subprocess入门介绍(可执行shell命令的模块)
    linux下 > /dev/null 2 > &1 的意思和如何在后台启动进程
  • 原文地址:https://www.cnblogs.com/yaok430/p/9082475.html
Copyright © 2020-2023  润新知