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. Visual Studio 快捷键、常见问题

    前言 由于平时自己在使用 VS 过程中遇到过一些很常见的问题,比如基本的设置.工具等.VS 十分的强大(宇宙第一 IDE),所以有些功能藏的深也不好找,就在这里记录下. 正文 一.快捷操作 1.调试. ...

  2. 7月新的开始 - Axure学习05 - 元件库的创建

    元件库的创建 元件库的创建.载入.编辑和删除等操作 元件库的后缀名名:.rplib 学习结果: 实现iPhone6的原型图 分辨率是 1080*1920,现在我们按比例缩小去实现(360*640)

  3. 利用python中的库文件简单的展示mnist 中的数据图像

    import sys, os sys.path.append('F:\ml\DL\source-code') #导入此路径中 from dataset.mnist import load_mnist ...

  4. 4.Python 进制和位运算

    .button, #logout { color: #333; background-color: #fff; border-color: #ccc; } span#login_widget > ...

  5. 使用openoffice转pdf,详细

    期由于项目的需求,需要word文档转pdf在线预览,由于一直没有接触这块,所以花了将近四天时间才弄明白. 写这篇文章的主要目的是加深自己的记忆,同时方便以后在用. (最近有使用了这个功能,发现这篇文章 ...

  6. [ARIA] Accessible modal dialogs

    Learn how to create a modal dialog with accessible keyboard and screen reader mechanics using the na ...

  7. LeetCode 269. Alien Dictionary

    原题链接在这里:https://leetcode.com/problems/alien-dictionary/ 题目: There is a new alien language which uses ...

  8. Vue动态创建注册component的实例代码

    https://segmentfault.com/a/1190000015698278

  9. PHP 判断给定两个时间是否在同一周,月,年

    判断是否在同一周 date_default_timezone_set('PRC'); //判断是否在同一周,原理:求出其中一个时间戳所在周的周一凌晨时间戳和周日24.00时间戳,如果另一个时间戳在这个 ...

  10. The backup set holds a backup of a database other than the existing ‘dbName’ database

     [Solved] System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than t ...