CentOS 开启防火墙及指定端口

CentOS 开启防火墙及指定端口

1. CentOS7

  • 查看防火墙状态

    [root@bogon ~]# firewall-cmd --state

  • 开启防火墙

    [root@bogon ~]# systemctl start firewalld.service

  • 重启防火墙

    [root@bogon ~]# systemctl restart firewalld.service

  • 关闭防火墙

    [root@bogon ~]# systemctl stop firewalld.service

  • 开启指定端口

    [root@bogon ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent

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

    重新加载后生效
    [root@bogon ~]# firewall-cmd reload

  • 查看已开启端口

    [root@bogon ~]# firewall-cmd --list-ports

2. CentOS6

猜你喜欢

转载自www.cnblogs.com/dkisyc/p/12205428.html