• 如何关闭firewall并开启iptables防火墙
  • 如何使用firewall防火墙

如何关闭firewall并开启iptables防火墙

1、停止firewall

systemctl stop firewalld.service

2、禁止firewall开机启动

systemctl disable firewalld.service

3、查看firewall运行状态(关闭后显示为not running,开启后显示running)

firewall-cmd --state

4、安装iptables-services

yum -y install iptables-services

5、修改防火墙的配置文件

vi /etc/sysconfig/iptables 

6、添加端口80,8080,3306,3690端口

-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3690 -j ACCEPT

请注意添加的位置,应在22端口的上面或者下面,但是不应在最底



7、重启防火墙

systemctl enable iptables.service

至此修改防火墙完毕




以下是iptables防火墙如何打开关闭,开机自启动等命令

查看防火墙状态:service iptables status

开启防火墙(重启后永久生效):chkconfig iptables on

关闭防火墙(重启后永久生效):chkconfig iptables off

开启防火墙(即时生效,重启后失效):service iptables start

关闭防火墙(即时生效,重启后失效):service iptables stop

重启防火墙:service iptables restartd

如何使用firewall防火墙

1.启动防火墙
systemctl start firewalld 2.禁用防火墙
systemctl stop firewalld 3.设置开机启动
systemctl enable firewalld 4.停止并禁用开机启动
sytemctl disable firewalld 5.重启防火墙
firewall-cmd --reload 6.查看状态
systemctl status firewalld或者 firewall-cmd --state 7.查看版本
firewall-cmd --version 8.查看帮助
firewall-cmd --help 9.查看区域信息
firewall-cmd --get-active-zones 10.查看指定接口所属区域信息
firewall-cmd --get-zone-of-interface=eth0 11.拒绝所有包
firewall-cmd --panic-on 12.取消拒绝状态
firewall-cmd --panic-off 13.查看是否拒绝
firewall-cmd --query-panic 14.将接口添加到区域(默认接口都在public)
firewall-cmd --zone=public --add-interface=eth0(永久生效再加上 --permanent 然后reload防火墙) 15.设置默认接口区域
firewall-cmd --set-default-zone=public(立即生效,无需重启) 16.更新防火墙规则
firewall-cmd --reload或firewall-cmd --complete-reload(两者的区别就是第一个无需断开连接,就是firewalld特性之一动态
添加规则,第二个需要断开连接,类似重启服务) 17.查看指定区域所有打开的端口
firewall-cmd --zone=public --list-ports 18.在指定区域打开端口(记得重启防火墙)
firewall-cmd --zone=public --add-port=80/tcp(永久生效再加上 --permanent)
说明:
–zone 作用域
–add-port=8080/tcp 添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

本文章笔记版本地址:http://ccdd6ec5.wiz03.com/share/s/3cTmX51TMQ-b2QTact03UPg81Cx5GE3-YkP62WU81u09UMFe

CentOS7 firewall与iptables防火墙的使用与开放端口的更多相关文章

  1. Ubuntu系统中防火墙的使用和开放端口

    目录 Ubuntu系统 防火墙的使用和开放端口 1.安装防火墙 2.查看防火墙状态 3.开启.重启.关闭防火墙 4.Ubuntu添加开放.关闭端口 5.开放规定协议的端口 6.关闭指定协议端口 7.开 ...

  2. Centos7下安装iptables防火墙

    说明:centos7默认使用的firewalld防火墙,由于习惯使用iptables做防火墙,所以在安装好centos7系统后,会将默认的firewall关闭,并另安装iptables进行防火墙规则设 ...

  3. 在centos7上安装iptables防火墙

    规则配置: iptables -P OUTPUT ACCEPT 1.关闭原先CentOS7自带的firewall防火墙: systemctl stop firewalld 2.安装或更新iptable ...

  4. CentOS7安装配置iptables防火墙

    转载请注明出处:http://blog.csdn.net/l1028386804/article/details/50779761 CentOS7默认的防火墙不是iptables,而是firewall ...

  5. linux中firewall与iptables防火墙服务

    火墙firewall-cmd --state 查看火墙的状态firewall-cmd --get-active-zones 目前所处的域firewall-cmd --get-default-zone ...

  6. 在iptables防火墙下开启vsftpd的端口

    在开启vsftpd端口后发现用客户端工具能登陆,但无法浏览文件和新建文件.此时看了一下ftp的协议,发现ftp有主动模式和被动模式.在服务端开21端口是让客户端进来,并没有出去的端口,还在服务端开启出 ...

  7. Iptables防火墙NAT地址转换与端口转发

    开启系统转发功能: [root@localhost /]# vim /etc/sysctl.conf # Generated by iptables-save v1.4.7 on Thu May 12 ...

  8. Linux 防火墙 | Linux 服务器如何开放端口 配置防火墙

    sudo ufw status(如果你是root,则去掉sudo,ufw status)可检查防火墙的状态,我的返回的是:inactive(默认为不活动).sudo ufw version防火墙版本: ...

  9. iptables防火墙常用命令

    iptables防火墙启动停止和基本操作 iptables是centos7之前常用的防火墙,在centos7上使用了firewall 防火墙基本操作: # 查询防火墙状态 service iptabl ...

随机推荐

  1. 详细阐述Web开发中的图片上传问题

    Web开发中,图片上传是一种极其常见的功能.但是呢,每次做上传,都花费了不少时间. 一个"小功能"花费我这么多时间,真心不愉快. So,要得认真分析下原因. 1.在最初学习Java ...

  2. 【rlz000】字串找数

    Time Limit: 3 second Memory Limit: 2 MB 问题描述 输入一个字符串,内有数字和非数字字符.如A123X456Y7A,302ATB567BC,统计共有多少个整数, ...

  3. 【t017】YL杯超级篮球赛

    Time Limit: 1 second Memory Limit: 256 MB [问题描述] 一年一度的高一YL杯超级篮球赛开赛了.当然,所谓超级的意思是参赛人数可能多于5人.小三对这场篮球赛非常 ...

  4. 【31.58%】【codeforces 682D】Alyona and Strings

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 再议指针---------函数回调(qsort函数原理)

    我们是否能写一个这种函数: 能够对不论什么类型数据排序 不论什么人在使用该函数不须要改动该函数代码(即:用户能够不必看到函数源 码,仅仅会调用即可) 思考: 用户须要排序的数据的类型千变万化,可能是i ...

  6. qemu使用copy-on-write(COW)磁盘

    写时复制(copy-on-write,缩写COW)技术不会对原始的镜像文件做更改,变化的部分写在另外的镜像文件中,这种特性在qemu中只有QCOW格式支持,多个 COW 文件可以指向同一映像同时测试多 ...

  7. 说下IEnumerable相关的

    IEnumerable 我们每天都在使用foreach进行遍历,今天讨论下面三个常见的问题: 为什么在foreach中不能修改item的值 要实现foreach需要满足什么条件 为什么Linq to ...

  8. 打开一个很好的介绍Lucene4 FST文章

    我没有看到源代码.看到这个博客了解一些基本的,像笔者下: http://download.csdn.net/download/guanxinquan/7380591 http://blog.sina. ...

  9. 解决 ubuntu 14.04.1 下一个sublime text3 3065 中国输入的问题

    你看今天 sublime text3 我以前有没有3059 的  它有支持3065该. 因此,为了支持subl  对中国输入法的实现 ,下面的操作步骤把我的记录供大家使用 有一个完整的教程:  htt ...

  10. 论题Cascade Object Detection with Deformable Part Models一个怀疑

    该文的作者是Pedro F. Felzenszwalb等一下,著名DPM在目标检测模型.本文的工作是DPM(变形组件模型)级联,以加快检测速度. 加速的方式,现在其次是计算总结成绩的某些部分,假设小于 ...