Centos 7 端口和防火墙命令:

查看已经开放的端口:firewall-cmd --list-ports

开启端口:firewall-cmd --zone=public --add-port=80/tcp --permanent

命令含义:

  –zone #作用域

  –add-port=80/tcp #添加端口,格式为:端口/通讯协议

  –permanent #永久生效,没有此参数重启后失效

重启防火墙:

  firewall-cmd --reload                          重启firewall
  systemctl stop firewalld.service 停止firewall
  systemctl disable firewalld.service 禁止firewall开机启动

1、firewalld的基本使用

启动: systemctl start firewalld

查看状态: systemctl status firewalld

停止: systemctl disable firewalld

禁用: systemctl stop firewalld

2.systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。


启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctlstop firewalld.service
重启一个服务:systemctlrestart firewalld.service
显示一个服务的状态:systemctlstatus firewalld.service
在开机时启用一个服务:systemctlenable firewalld.service
在开机时禁用一个服务:systemctldisable firewalld.service
查看服务是否开机启动:systemctlis-enabled firewalld.service
查看已启动的服务列表:systemctllist-unit-files|grep enabled
查看启动失败的服务列表:systemctl--failed


3.配置firewalld-cmd

查看版本: firewall-cmd --version

查看帮助: firewall-cmd --help

显示状态: 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


查看firewall是否运行,下面两个命令都可以

systemctl status firewalld.service

firewall-cmd --state

查看当前开了哪些端口


其实一个服务对应一个端口,每个服务对应/usr/lib/firewalld/services下面一个xml文件。


firewall-cmd --list-services

 

CentOS 7 以下版本 iptables 命令

如要开放80,22,8080 端口,输入以下命令即可

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

然后保存:/etc/rc.d/init.d/iptables save


查看打开的端口:/etc/init.d/iptables status

关闭防火墙 
1) 永久性生效,重启后不会复原

  开启: chkconfig iptables on

  关闭: chkconfig iptables off

2) 即时生效,重启后复原

  开启: service iptables start

  关闭: service iptables stop

CentOS 端口和防火墙操作的更多相关文章

  1. CentOS 7.0 防火墙操作

    CentOS 7.0默认使用的是firewall作为防火墙,之前版本是使用iptables.所以在CentOS 7执行下面命令是无法查看防火墙状态的. [root@localhost ~]# serv ...

  2. CentOS 配置防火墙操作实例(启、停、开、闭端口):

    CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作命令: 查询防火墙状态: [root@localhost ~]# service   iptables status< ...

  3. CentOS 配置防火墙操作实例(启、停、开、闭端口)CentOS Linux-FTP/对外开放端口(接口)TomCat相关

    链接地址:http://blog.csdn.net/jemlee2002/article/details/7042991 CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作 ...

  4. CentOS系统iptables防火墙的启动、停止以及开启关闭端口的操作

    CentOS 配置防火墙操作实例(启.停.开.闭端口):注:防火墙的基本操作命令:查询防火墙状态:[root@localhost ~]# service   iptables status停止防火墙: ...

  5. CentOS配置防火墙操作实例

    CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作命令: 查询防火墙状态: [root@localhost ~]# service iptables status<回 ...

  6. CentOS 7 开放防火墙端口

    我:最近在使 CentOS 7时发现在本地不能访问linux上8080端口,以上是我的操作,修改后访问成功 CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现 ...

  7. CentOS中iptables防火墙 开放80端口方法

    开放端口:  代码如下 复制代码 [root@WX32 ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT 保存配置:  代码如下 复制代码 [root ...

  8. CentOS 7 开放防火墙端口命令

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  9. CentOS 7 开放防火墙端口 命令(转载)

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

随机推荐

  1. git 获取 remote 的 url

    git 获取 remote 的 url git ls-remote --get-url [remote] 例如: git ls-remote --get-url origin  

  2. JS闭包是什么?

    闭包是js开发惯用的技巧,什么是闭包? 闭包指的是:能够访问另一个函数作用域的变量的函数. 清晰的讲:闭包就是一个函数,这个函数能够访问其他函数的作用域中的变量. function outer(){ ...

  3. jquery模仿淘宝星星打分

    今天做论坛页面有星星评分功能,以下是代码.用的时候引入jquery <span> <ul class="hs_df_xx"> <li><i ...

  4. 怎能使用echo 输出对象

     class A{         function __toString() {             return "怎么使用echo输出对象";          }   ...

  5. Devtool-Console

    1. console面板展示 1.全屏展示 打开开发者工具(option+cmd+i),点击console的tab 2. 在其他面板展示的同时展示console面板 1)esc快捷命令 2)或者选择打 ...

  6. bootstrap-wysihtml5 ckeditor 修改富文本编辑器可以上传图片

    bootstrap-wysihtml5 ckeditor 修改富文本编辑器可以上传图片   bootstrap-wysihtml5实际使用内核为ckeditor     故这里修改ckeditor即可 ...

  7. 013_Python3 条件控制

    1.if #!/usr/bin/python3   var1 = 100 if var1:     print ("1 - if 表达式条件为 true")     print ( ...

  8. 后台(一)vue+element-ui (按需加载)

    vue init webpack    项目名称 npm install axios                    //先安装! npm install --save axios vue-ax ...

  9. TensorFlow(六):tensorboard网络结构

    # MNIST数据集 手写数字 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # ...

  10. Python3数字

    Python3数字数据类型用于存储数值. 数据类型是不允许改变的,这就意味着,如果改变数字数据类型的值,将重新分配内存空间. Python支持三种不同不同的数值类型: 整型(int):通常是被称为整型 ...