- Security Automation with Ansible 2
- Madhu Akula Akash Mahajan
- 201字
- 2021-07-02 22:00:00
Hardening a host firewall service
The following code snippet is for installing and configuring the uncomplicated firewall (UFW) with its required services and rules. Ansible even has a module for UFW, so the following snippet starts with installing this and enabling logging. It follows this by adding default policies, like default denying all incoming and allowing outgoing.
Then it will add SSH, HTTP, and HTTPS services to allow incoming. These options are completely configurable, as required. Then it will enable and add to startup programs that apply the changes:
- name: installing ufw package apt:
name: "ufw"
update_cache: yes
state: present - name: enable ufw logging ufw:
logging: on - name: default ufw setting ufw:
direction: "{{ item.direction }}"
policy: "{{ item.policy }}"
with_items: - { direction: 'incoming', policy: 'deny' } - { direction: 'outgoing', policy: 'allow' } - name: allow required ports to access server ufw:
rule: "{{ item.policy }}"
port: "{{ item.port }}"
proto: "{{ item.protocol }}" with_items: - { port: "22", protocol: "tcp", policy: "allow" } - { port: "80", protocol: "tcp", policy: "allow" } - { port: "443", protocol: "tcp", policy: "allow" } - name: enable ufw ufw:
state: enabled - name: restart ufw and add to start up programs service:
name: ufw
state: restarted
enabled: yes
推薦閱讀
- ABB工業(yè)機器人編程全集
- 面向STEM的mBlock智能機器人創(chuàng)新課程
- 計算機圖形學(xué)
- 人工免疫算法改進(jìn)及其應(yīng)用
- 空間機器人遙操作系統(tǒng)及控制
- 條碼技術(shù)及應(yīng)用
- ROS機器人編程與SLAM算法解析指南
- 大數(shù)據(jù)安全與隱私保護(hù)
- RPA:流程自動化引領(lǐng)數(shù)字勞動力革命
- 網(wǎng)絡(luò)綜合布線設(shè)計與施工技術(shù)
- Excel 2007技巧大全
- Silverlight 2完美征程
- 電氣控制及Micro800 PLC程序設(shè)計
- FreeCAD [How-to]
- Flash CS5二維動畫設(shè)計與制作