当前位置:网站首页>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
边栏推荐
- Source insight automatic installation and licensing
- 配置xml文件的dtd
- Transferring images using flask
- BIO、NIO、AIO区别
- Simpleitk learning notes
- Why should we rewrite hashcode when we rewrite the equals method?
- The IntelliJ platform completely disables the log4j component
- 音频焦点系列:手写一个demo理解音频焦点与AudioMananger
- [basic grammar] Snake game written in C language
- Yolov5 model construction source code details | CSDN creation punch in
猜你喜欢

6.23星期四库作业

BTC-密码学原理
![[practical project] autonomous web server](/img/99/892e600b7203c63bad02adb683c8f2.png)
[practical project] autonomous web server

JS dynamic table creation

Map的扩容机制

@Autowired 导致空指针报错 解决方式

XML配置文件

Progressive multi grasp detection using grasp path for rgbd images

Congratulations to musk and NADELLA on their election as academicians of the American Academy of engineering, and Zhang Hongjiang and Fang daining on their election as foreign academicians
![[basic grammar] Snake game written in C language](/img/cb/83631ef3ccd7047ca42d33dc49bf90.jpg)
[basic grammar] Snake game written in C language
随机推荐
期末复习DAY8
(perfect solution) how to set the position of Matplotlib legend freely
Go language interface learning notes Continued
Primary school campus IP network broadcasting - Design of primary school IP digital broadcasting system based on campus LAN
How to set up altaro offsite server for replication
Latest version of source insight
Introduction to redis and explanation of data types
Go practice -- use redis in golang (redis and go redis / redis)
Intégration profonde et alignement des séquences de protéines Google
Skip table: principle introduction, advantages and disadvantages of skiplist
Classification and discussion of plane grab detection methods based on learning
The IntelliJ platform completely disables the log4j component
Shanghai daoning, together with American /n software, will provide you with more powerful Internet enterprise communication and security component services
How do I migrate my altaro VM backup configuration to another machine?
Altaro virtual machine replication failed: "unsupported file type vmgs"
Jetson AGX Orin 平台移植ar0233-gw5200-max9295相机驱动
Yolov5 input (II) | CSDN creative punch in
es7创建索引容易犯的错误
大二困局(复盘)
Progressive multi grasp detection using grasp path for rgbd images