CentOS7防火墙firewalld 和 CentOS6防火墙iptables的一些配置命令
CentOS7 防火墙
一、防火墙的开启、关闭、禁用、查看状态命令
(1)启动防火墙:systemctl start firewalld
(2)关闭防火墙:systemctl stop firewalld
(3)设置开机启用防火墙:systemctl enable firewalld
(4)设置开机禁用防火墙:systemctl disable firewalld
(5)检查防火墙状态:systemctl status firewalld
二、使用firewall-cmd命令配置端口
(1)查看防火墙状态:firewall-cmd --state
(2)重新加载配置:firewall-cmd --reload
(3)查看已开放的端口:firewall-cmd --list-ports
(4)开放防火墙端口:firewall-cmd --zone=public --add-port=10050/tcp --permanent
命令含义:
–zone #作用域
–add-port=10050/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
注意:添加端口后,必须用命令firewall-cmd --reload重新加载一遍 或者systemctl restart firewalld重启防火墙才会生效
(5)关闭防火墙端口:firewall-cmd --zone=public --remove-port=9200/tcp --permanent
CentOS6 防火墙
一、防火墙的开启、关闭、禁用、查看状态命令
[root@localhost ~]# cd ~ //注意:要进入到~目录 也就是家目录下才能查看防火墙
(1)启动防火墙:service iptables start
(2)关闭防火墙:service iptables stop
(3)设置开机启用防火墙:chkconfig iptables on
(4)设置开机禁用防火墙:chkconfig iptables off
(5)检查防火墙状态:service iptables status
二、添加需要放开的服务器端口
[root@localhost ~]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT //比如我要添加80端口,其他端口只需要把80换成需要添加的端口就可以了
添加后重启防火墙:
[root@localhost ~]# service iptables start
以下为我的服务器的防火墙规则
[root@localhost ~]# vi /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 60101 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 10050:10051 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 10050:10051 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
CentOS7防火墙firewalld 和 CentOS6防火墙iptables的一些配置命令的更多相关文章
- CentOS7 防火墙firewalld 和 CentOS6 防火墙iptables 开放zabbix-agent端口的方法
我们在生产环境中,一般都是把防火墙打开的,不像测试环境,可以直接关闭掉.最近安装zabbix ,由于公司服务器既有centos 7又有centos 6,遇到了一些防火墙的问题,现在正好把centos防 ...
- CentOS7使用firewalld打开关闭防火墙与端口(转载)
1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disabl ...
- 关于学习CentOS7使用firewalld打开关闭防火墙和端口
1.firewalld简介 firewalld是centos7的一大特点,主要有两个优点:一是支持动态更新,不需要重启服务:二就是加入了防火墙的“zone”概念. firewalld有图形界面和工具界 ...
- CentOS7使用firewalld打开关闭防火墙与端口(转)
CentOS7使用firewalld打开关闭防火墙与端口 1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop ...
- 第一篇:动态防火墙firewalld和静态防火墙iptables
动态防火墙firewalld firewalld提供了一个动态管理的防火墙,它支持网络(network)/防火墙区域(firewall zones )来定义网络连接( network connecti ...
- 转 CentOS7使用firewalld打开关闭防火墙与端口
http://blog.csdn.net/huxu981598436/article/details/54864260 开启端口命令 输入firewall-cmd --query-port=6379/ ...
- CentOS7使用firewalld打开关闭防火墙与端口
1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disab ...
- CentOS7 使用firewalld打开关闭防火墙与端口
1.firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status f ...
- CentOS7 使用firewalld打开关闭防火墙以及端口
1.firewalld的基本使用 启动 systemctl start firewalld 关闭 systemctl stop firewalld 查看状态 systemctl status fire ...
随机推荐
- 2、Spring的IOC标签介绍以及实例
一.Spring_ioc配置文件bean标签介绍 1. bean标签 名称:bean 类型:标签 归属:beans标签 作用:定义spring中的资源,受此标签定义的资源将受到spring控制 格式: ...
- shell脚本 系统信息检测
一.简介 源码地址 日期:2018/4/12 介绍:根据指令展示不同的系统数据 效果图: 二.使用 适用:centos6+ 语言:中文 注意:无 下载 wget https://raw.githubu ...
- 手把手教你提交Jar包到Maven公共仓库 | 萌新写开源02
在上一篇文章中,我介绍了自己的SpringBoot Starter项目,可以让我们使用注解的方式轻松地获取操作日志,并推送到指定数据源. 之前,我的项目开源在Github上,大家想要用我的项目,还得把 ...
- java多线程6:ReentrantLock
下面看下JUC包下的一大并发神器ReentrantLock,是一个可重入的互斥锁,具有比synchronized更为强大的功能. ReentrantLock基本用法 先来看一下ReentrantLoc ...
- Table.Distinct取唯/众数….Distinct/Mode/判断…IsDistinct(Power Query 之 M 语言)
数据源: "姓名""基数""个人比例""个人缴纳""公司比例""公司缴纳"&qu ...
- AtCoder Beginner Contest 172 题解
AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...
- 端云协同,打造更易用的AI计算平台
内容来源:华为开发者大会2021 HMS Core 6 AI技术论坛,主题演讲<端云协同,HUAWEI HiAI Foundation打造更易用的AI计算平台>. 演讲嘉宾:华为海思AI技 ...
- JAVA直接连接Redis
引入maven <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</ ...
- mysql三种提交类型
mysql提交分显式提交.隐式提交及自动提交. (1) 显式提交用COMMIT命令直接完成的提交为显式提交.其格式为:SQL>COMMIT: (2) 隐式提交用SQL命令间接完成的提交为隐式提交 ...
- SpringCloud(三) Zuul
Zuul 有了eureka . feign 和 hystrix 后,基本上就搭建了简易版的分布式项目,但仍存在一些问题,比如: 1.如果我们的微服务中有很多个独立服务都要对外提供服务,那么我们要如何去 ...