CentOS 端口和防火墙操作
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 端口和防火墙操作的更多相关文章
- CentOS 7.0 防火墙操作
CentOS 7.0默认使用的是firewall作为防火墙,之前版本是使用iptables.所以在CentOS 7执行下面命令是无法查看防火墙状态的. [root@localhost ~]# serv ...
- CentOS 配置防火墙操作实例(启、停、开、闭端口):
CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作命令: 查询防火墙状态: [root@localhost ~]# service iptables status< ...
- CentOS 配置防火墙操作实例(启、停、开、闭端口)CentOS Linux-FTP/对外开放端口(接口)TomCat相关
链接地址:http://blog.csdn.net/jemlee2002/article/details/7042991 CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作 ...
- CentOS系统iptables防火墙的启动、停止以及开启关闭端口的操作
CentOS 配置防火墙操作实例(启.停.开.闭端口):注:防火墙的基本操作命令:查询防火墙状态:[root@localhost ~]# service iptables status停止防火墙: ...
- CentOS配置防火墙操作实例
CentOS 配置防火墙操作实例(启.停.开.闭端口): 注:防火墙的基本操作命令: 查询防火墙状态: [root@localhost ~]# service iptables status<回 ...
- CentOS 7 开放防火墙端口
我:最近在使 CentOS 7时发现在本地不能访问linux上8080端口,以上是我的操作,修改后访问成功 CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现 ...
- CentOS中iptables防火墙 开放80端口方法
开放端口: 代码如下 复制代码 [root@WX32 ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT 保存配置: 代码如下 复制代码 [root ...
- CentOS 7 开放防火墙端口命令
CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...
- CentOS 7 开放防火墙端口 命令(转载)
CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...
随机推荐
- 轻院校赛-zzuli 2266: number【用每位的二进制的幂的和来进行hash(映射)处理】
zzuli 2266: number 大致题意: 给定n,问有多少数对<x, y>满足: x, y∈[1, n], x < y x, y中出现的[0, 9] ...
- m_strcmp
strcmp比较两个字符串的大小,strcmp(str1, str2); 从str1和str2的第一个元素比较直到出现不同,或者遇到'\0'结束.如果str1 > str2 返回正数,str1 ...
- Java下的tinylog日志打印
做个笔记. 做某个功能时需要DEBUG调试日志,但是直接System.out.println 是打印在终端,有些情况下是看不到输出的,所以需要用日志框架去打印输出值. 经过搜索完以后发现Logback ...
- ES6中构造函数内super关键字的使用
super关键字用于访问和调用一个对象的父对象上的函数. super.prop和super[expr]表达式在类和对象字面量任何方法定义中都是有效的. 语法 super([arguments]); / ...
- 网络编程 --- subprocess模块,struct模块,粘包,UDP协议,socket_server模块
目录 subprocess模块 struct模块 粘包 UDP协议 socket_server模块 subprocess模块 作用: 1.可以帮你通过代码执行操作系统的终端命令 2.并返回终端执行命令 ...
- MySql更改用户密码
1. use mysql show tables;查看mysql数据库中的表,会看到一个user表. select * from user;查看一下这个表中是否有root用户,如果有: update ...
- Codeforces Round #336 (Div. 2) D. Zuma(区间DP)
题目链接:https://codeforces.com/contest/608/problem/D 题意:给出n个宝石的颜色ci,现在有一个操作,就是子串的颜色是回文串的区间可以通过一次操作消去,问最 ...
- PostgreSQL 不要使用kill -9 杀 Postgresq 用户进程
转载:http://francs3.blog.163.com/blog/static/4057672720109854858308/ Postgresql 8.3.3 今天应用反映数据库很慢,有些SQ ...
- js文件上传下载组件
在Web应用系统开发中,文件上传和下载功能是非常常用的功能,今天来讲一下JavaWeb中的文件上传和下载功能的实现. 先说下要求: PC端全平台支持,要求支持Windows,Mac,Linux 支持所 ...
- [luogu] zpl的数学题1
https://www.luogu.org/problemnew/show/U16887 $f[1] + f[2] + f[3] + .... + f[n] = f[n + 2] - 1$ 矩阵快速幂 ...