当前位置:网站首页>ansible防火墙firewalld设置
ansible防火墙firewalld设置
2022-07-03 05:31:00 【水步天】
背景
防火墙 通过有机结合各类用于安全管理与筛选的软件和硬件设备,帮助计算机网络于其内、外网之间构建一道相对隔绝的保护屏障,以保护用户资料与信息安全性的一种技术。
就计算机而言防火墙分硬件和软件之分,本篇是从软件角度的防火墙出发,针对操作系统自带的防火墙技术展开介绍。
在程序部署阶段防火墙的设置是常见的操作之一。本篇以ansible为载体介绍,传统防火墙设置参考《centos7 防火墙设置》
需求
针对分配的服务器进行防火墙的开关、端口策略和服务的设置操作。
操作
ansible操作防火墙中在本篇中涉及到三部分的内容
- 防火墙的开关
- 防火墙端口策略
- 防火墙服务策略
防火墙的开关
防火墙的开关使用到的是ansible 中的service服务
打开
# 开启firewalld服务
- hosts: middleware
# 远程执行任务用户
remote_user: root
# 任务列表
tasks:
# 获取系统内服务信息
- name: checking service
ansible.builtin.service_facts:
# 声明
- name: 开启firewalld防火墙
service:
name: firewalld
state: started
enabled: yes
when: ansible_facts.services['firewalld.service'] is defined
如果需要关闭防火墙将state状态设置为 stopped
验证
$ ansible middleware -a 'systemctl status firewalld' -i hosts
防火墙端口策略
打开
# 设置firewalld端口策略
- hosts: middleware
# 远程执行任务用户
remote_user: root
# 任务列表
tasks:
# 声明
- name: 设置firewalld端口策略
firewalld:
port: 8848/tcp
state: enabled
permanent: yes
immediate: yes
验证
$ ansible middleware -m shell -a 'firewall-cmd --lists-ports' -i hosts
防火墙服务策略
打开
# 设置firewalld服务策略
- hosts: middleware
# 远程执行任务用户
remote_user: root
# 任务列表
tasks:
# 声明
- name: 设置firewalld服务策略
firewalld:
service: http
state: enabled
permanent: yes
immediate: yes
验证
$ ansible middleware -m shell -a 'firewall-cmd --lists-services' -i hosts
边栏推荐
- How do I migrate my altaro VM backup configuration to another machine?
- Chapter II program design of circular structure
- Webrtc M96 release notes (SDP abolishes Plan B and supports opus red redundant coding)
- Yolov5 model construction source code details | CSDN creation punch in
- 2022.7.2day594
- 求质数的方法
- Redis breakdown penetration avalanche
- Altaro virtual machine replication failed: "unsupported file type vmgs"
- 期末复习(day3)
- Botu uses peek and poke for IO mapping
猜你喜欢
Shanghai daoning, together with American /n software, will provide you with more powerful Internet enterprise communication and security component services
[set theory] relational power operation (relational power operation | examples of relational power operation | properties of relational power operation)
Yolov5 network structure + code + application details | CSDN creation punch in
Deploy crawl detection network using tensorrt (I)
"C and pointer" - Chapter 13 function pointer 1: callback function 2 (combined with template to simplify code)
Skip table: principle introduction, advantages and disadvantages of skiplist
XML Configuration File
(subplots用法)matplotlib如何绘制多个子图(轴域)
Use posture of sudo right raising vulnerability in actual combat (cve-2021-3156)
【实战项目】自主web服务器
随机推荐
ROS Compilation Principle
期末复习(Day5)
"C and pointer" - Chapter 13 advanced pointer int * (* (* (*f) () [6]) ()
Go language interface learning notes
EMD distance - example of use
Yolov5 input (I) -- mosaic data enhancement | CSDN creative punch in
appium1.22.x 版本後的 appium inspector 需單獨安裝
Webrtc protocol introduction -- an article to understand ice, stun, NAT, turn
Xaml gradient issue in uwp for some devices
JS string and array methods
Basic introduction of redis and explanation of eight types and transactions
乾元通多卡聚合路由器的技术解析
Shanghai daoning, together with American /n software, will provide you with more powerful Internet enterprise communication and security component services
How to set up altaro offsite server for replication
Brief introduction of realsense d435i imaging principle
(完美解决)matplotlib图例(legend)如何自由设置其位置
Deep embedding and alignment of Google | protein sequences
Go practice -- closures in golang (anonymous functions, closures)
Rust基础入门之(基本类型)
Chapter II program design of circular structure