CentOS中防火墙程序主要是firewall和iptables两种。

CentOS7中firewall服务已经默认安装好了,而iptables服务需要自己用yum install  iptabes-services来安装。


1、firewall防火墙操作

1.1 基本操作

操作命令

启动           systemctl start firewalld

关闭           systemctl  stop firewalld

查看状态    systemctl status firewalld

开机禁用    systemctl disable firewalld

开机启用    systemctl enable firewalld

查看版本    firewall-cmd --version

查看列表    firewall-cmd --list-all

1.2 开启一个防火墙端口

① 添加端口

firewall-cmd--add-port=3306/tcp --permanent

(--permanent永久生效,没有此参数重启后失效)

② 重新载入                          firewall-cmd --reload

③ 查看所有打开的端口        firewall-cmd --list-ports

1.3 删除一个已开启的端口

firewall-cmd --remove-port=3306/tcp--permanent


2、iptables防火墙操作

2.1 切换到iptables首先应该关掉默认的firewalld,然后安装iptables服务。

#关闭firewall                        service firewalld stop

#禁止firewall开机启动         systemctl disablefirewalld.service

#安装iptables防火墙            yum install iptables-services

2.2 Iptables防火墙基本操作

操作命令

查看防火墙状态    service  iptables status

停止防火墙           service  iptables stop

启动防火墙           service  iptables start

永久关闭防火墙    chkconfig  iptables off

永久关闭后重启    chkconfig  iptables on

2.3 编辑iptables防火墙配置

vi /etc/sysconfig/iptables

以下是配置文件示例,编辑自己的规则

 

依照其中22端口,添加自己需要的端口

:wq保存退出后重启防火墙

service iptablesrestart

CentOS7下,防火墙设置的更多相关文章

  1. Linux下防火墙设置

    Linux下开启/关闭防火墙命令  1) 永久性生效,重启后不会复原 开启:chkconfigiptables on 关闭:chkconfigiptables off 2) 即时生效,重启后复原 开启 ...

  2. Centos7.5 防火墙设置

    Centos7.5默认使用firewalld作为防火墙 1.查看firewalld服务状态 systemctl status firewalld 2.查看firewalld的状态 firewall-c ...

  3. centos7.3 防火墙设置

    1.查看firewall服务状态 systemctl status firewalld 2.查看firewall的状态 firewall-cmd --state 3.开启.重启.关闭.firewall ...

  4. centos7.4 防火墙设置

    1.关闭默认的firewall防火墙 systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service ...

  5. Centos7下Redis设置开机自启动服务

    有个同事说重启了服务器没有自启动redis,我看了一下,是以前手动编译安装的模式,没有配置开机启动的服务 这边做个笔记记录一下redis如何设置编译安装模式的开机自启动. 第一种方法: 1.编写red ...

  6. Centos7下chkconfig设置MySql自动启动

    1.将服务文件拷贝到init.d下,并重命名为mysql cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 2.赋予可执 ...

  7. Centos7关闭防火墙 设置开机启动

    [root@nmserver-7 ~]# systemctl stop firewalld.service [root@nmserver-7 ~]# systemctl status firewall ...

  8. centos7开放端口和防火墙设置

    centos7开放端口和防火墙设置. 查看防火墙状态: firewall-cmd --state 如果显示: not running 打开防火墙服务: systemctl start firewall ...

  9. (9)centos下防火墙firewalld设置

    学习apache安装的时候需要打开80端口,由于centos 7版本以后默认使用firewalld后,网上关于iptables的设置方法已经不管用了,想着反正iptable也不会用,索性直接搬官方文档 ...

  10. CentOS7防火墙设置常用命令

    目录 开/关/重启防火墙 查看所有开启的端口号 CentOS7环境下防火墙常用命令 开/关/重启防火墙 查看防火墙状态 firewall-cmd --state 启动防火墙 systemctl sta ...

随机推荐

  1. hdu2824 The Euler function(欧拉函数个数)

    版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/36426357 题目链接:h ...

  2. Docker删除/停止容器

    应用场景:某个相关的业务需要重启,容器太多了,一个一个通过命令行来关闭太麻烦了,直接一条命令直接搞定. 命令如下: $ docker ps // 查看所有正在运行容器 $ docker stop co ...

  3. 【css】css实现点击Toggle功能/icon切换

    ①实现Toggle功能 html结构: <div class="cssTog"><label> <p> 专业:B020309现代企业管理(独立本 ...

  4. 文本处理三剑客之 awk

    GAWK:报告生成器,格式化文本输出 awk [options] ‘program’ var=value file… awk [options] -f programfile var=value fi ...

  5. Delphi按名字调用方法高级解决方案

    转帖于https://lfzhs.iteye.com/blog/980200 按名字调用方法似乎一直以来都是大家比较关注的技术,在论坛上有一个经典的答复: type TProcedure = proc ...

  6. 01.创建winserver2012r2+hyper-v+centos7

    1.背景 DELL poweredge T320,装的winserver2012 r2,利用自带的hyper-v安装centos7,后期主要用于spark开发. 1.1 安装winserver2012 ...

  7. a simple game based on RT-Thread

    [作品名称] a simple game based on RT-Thread [背景描述] 学了一段时间的嵌入式操作系统RT-Thread,发现是真的好用.于是想做一个小作品来锻炼巩固自己学习的知识 ...

  8. Glide Golang包管理

    Golang的包管理乱得不行,各种工具横空出世,各显神通啊.用了几个下来,发现 Glide 是比较好用的,使用了 vender 来进行管理,多个开发环境的版本不冲突,功能强大,配置文件也足够简单. 初 ...

  9. HTTP性能测试工具wrk安装及使用

    wrk 是一个很简单的 http 性能测试工具,没有Load Runner那么复杂,他和 apache benchmark(ab)同属于HTTP性能测试工具,但是比 ab 功能更加强大,并且可以支持l ...

  10. Taming the asynchronous beast with ES7

    https://pouchdb.com/2015/03/05/taming-the-async-beast-with-es7.html We have a problem with promises ...