centos7 防火墙命令

  • 防火墙的开启、关闭、禁用命令
  • 防火墙端口命令

防火墙的开启、关闭、禁用命令

启动防火墙服务

[root@localhost jinjia523]# systemctl start firewalld.service

关闭防火墙服务

[root@localhost jinjia523]# systemctl stop firewalld.service

重启防火墙服务

[root@localhost jinjia523]# systemctl restart firewalld.service

重载防火墙服务

[root@localhost jinjia523]# systemctl reload firewalld.service

在开机时启用防火墙服务

[root@localhost jinjia523]# systemctl enable firewalld.service
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.

在开机时禁用防火墙服务

[root@localhost jinjia523]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

显示防火墙服务的状态(详细信息):

[root@localhost jinjia523]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: active (running) since 二 2021-02-02 06:46:32 PST; 1min 59s agoDocs: man:firewalld(1)Process: 4878 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)Main PID: 4654 (firewalld)Tasks: 2Memory: 22.6MCGroup: /system.slice/firewalld.service└─4654 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete FORWARD --in-interface virbr0 -... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete FORWARD --out-interface virbr0 ...hat name.
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete FORWARD --in-interface virbr0 -...hat name.
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete INPUT --in-interface virbr0 --p... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete INPUT --in-interface virbr0 --p... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete OUTPUT --out-interface virbr0 -... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete INPUT --in-interface virbr0 --p... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --delete INPUT --in-interface virbr0 --p... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables... chain?).
2月 02 06:47:14 localhost.localdomain firewalld[4654]: WARNING: COMMAND_FAILED: '/usr/sbin/iptables -w10 -D FORWARD -i docker0 -o docker0 -j DROP' failed: iptables... chain?).
Hint: Some lines were ellipsized, use -l to show in full.

显示防火墙服务的状态是否允许:

[root@localhost jinjia523]# firewall-cmd --state
running

防火墙端口命令

添加一个端口(–permanent永久生效,没有此参数重启后失效)

[root@localhost jinjia523]# firewall-cmd --zone=public --add-port=9000/tcp --permanent
success

删除一个端口

[root@localhost jinjia523]# firewall-cmd --zone=public --remove-port=9000/tcp --permanent
success

查看端口是否开放

[root@localhost jinjia523]# firewall-cmd --zone=public --query-port=8080/tcp
yes

命令含义:

  • –zone #作用域
  • –add-port=9200/tcp #添加端口,格式为:端口/通讯协议
  • –permanent #永久生效,没有此参数重启后失效

重新载入(添加完端口需要重新载入否则不会立即生效)

[root@localhost jinjia523]# firewall-cmd --reload
success

查看开放的端口

[root@localhost jinjia523]# firewall-cmd --list-ports
7000-9000/tcp 22122/tcp 23000/tcp

centos7 防火墙命令相关推荐

  1. centos7防火墙命令汇总

    centos7防火墙命令汇总 1.安装firewall命令 2.查看防火墙状态 3.查看已开放端口 4.开启端口 5.关闭端口 6.指定特定源IP访问某端口 7.批量添加区间端口 8.查看端口列表 9 ...

  2. centos7防火墙命令

    安装Firewall命令: yum install firewalld firewalld-config 使用firewall-cmd 命令 查看状态 firewall-cmd --state //r ...

  3. 保存linux防火墙配置,centos7 防火墙配置文件_centos7保存防火墙配置

    原标题:centos7 防火墙配置文件_centos7保存防火墙配置 修改防火墙配置文件之前需要对之前防火墙做好备份 重启防火墙后需要确认防火墙状 2.systemctl是CentOS7的服务管理工具 ...

  4. 下防火墙命令与centos7下防火墙命令区别

    一.centos6防火墙命令  1.查看防火墙规则  #iptables -L  2.状态.开启.关闭.重启防火墙  #service iptables status  #service iptabl ...

  5. linux防火墙开放所有端口命令,linux centos7 防火墙及端口开放相关命令

    一.防火墙相关命令 1.查看防火墙状态 : systemctl status firewalld.service 注:active是绿的running表示防火墙开启 2.关闭防火墙 :systemct ...

  6. centos7 ifconfig命令找不到_centos7+mysql+gunicorn+flask项目部署

    前言 出于学习和实践的目的,近期自己写了一个小项目关于flask的API项目,涉及到服务器的上线部署问题,这里就做一个详细的记录和分享吧~欢迎一起交流学习指正~ 正文 一.centos7安装pytho ...

  7. Linux:CentOS7防火墙基本操作

    目录 前言 防火墙开启.关闭.以及查看防火墙状态命令 查看防火墙状态 如下表示防火墙开启中 active (running) 如下表示防火墙关闭中 inactive (dead) 开启防火墙 关闭防火 ...

  8. linux7配置开启防火墙,CentOS7防火墙设置

    CentOS7 与之前版本在防火墙配置上不同,防火墙从iptables变成了firewalld Centos7默认安装了firewalld,如果没有安装的话,可以使用yum命令进行安装 yum ins ...

  9. linux安装nginx防火墙,Centos7 防火墙关闭与nginx无法访问

    默认情况下,Centos7防火墙是打开的,如果你没有关闭他,你安装nginx后启动,是无法访问到nginx服务的. 所以需要做这件事 1.启动nginx 启动前先看它启动没有,通过linux命令查看所 ...

最新文章

  1. 洛谷8月赛Div.2
  2. Objective-C:保留计数器思想的详解(对象的保留和所有权的释放)
  3. hdu 1872(看病要排队)(优先队列)
  4. 微信公众平台消息接口开发(13)多语种互译
  5. 欧姆龙plc解密实例_3000多套PLC实例程序大合集自动控制系统程序电气系统程序...
  6. TensorFlow2简单入门-三维张量
  7. python2.7配置tensorflow1.5.0和keras2.1.6
  8. windows XP cmd命令集
  9. 不会英语能学oracle吗,英语非常差该怎么学啊?
  10. Python 3 报错 TypeError: object() takes no parameters【新手必过坑之一】
  11. LeetCode 326. Power of Three
  12. 数据结构上机实践第八周项目8-稀疏矩阵的三元组表示的实现及应用
  13. 写一个上班看股票的小软件
  14. 从零开始写一个Jison解析器(7/10):解析器生成器 `parser generator` 的迭代式开发流程
  15. 第一行代码-第二版(郭霖著)笔记(初识Android)
  16. 2020 android平板推荐,2020年2000元左右的平板哪一款好?2000元左右的平板推荐
  17. 分水岭算法--语义分割
  18. java 直线交点_[Java教程]谈谈求线段交点的几种算法(js实现,完整版)
  19. 【ecshop---新增包邮卡功能】
  20. H5移动端实现图片上传

热门文章

  1. 苹果Mac没有声音,喇叭显示为灰色禁用状态如何解决?
  2. 2013 08 12 Andrew:C语言的一点心得
  3. 为了满足微型计算机,超高清分辨率畅玩游戏大作,这三套配置总有一套满足你...
  4. C#读取word中表格数据
  5. 路由器逆向分析------在Linux上安装IDA Pro
  6. int 3中断与软件调试
  7. 组织结构图OrgChart.js
  8. Echarts 极坐标系下的多色柱状图
  9. laravel 上传文件的方式汇总
  10. 自动更新host实现github加速