-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from ehh-why-its-so-hard/firewall
Firewall
- Loading branch information
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
firewall_open_tcp: [] | ||
firewall_open_udp: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
# How it works? | ||
# OUTPUT: allowed everywhere | ||
# INPUT: blocked all except 22 and specific ports | ||
|
||
- name: Uninstall unsupported firewalls | ||
ansible.builtin.apt: | ||
pkg: | ||
- ufw | ||
- firewalld | ||
state: absent | ||
|
||
- name: Install iptables | ||
ansible.builtin.apt: | ||
pkg: | ||
- iptables | ||
- iptables-persistent | ||
state: present | ||
|
||
- name: Template restore file | ||
ansible.builtin.template: | ||
src: "etc/iptables-restore.apply" | ||
dest: "/etc/iptables-restore.apply" | ||
owner: "root" | ||
group: "root" | ||
mode: "0644" | ||
register: iptables_restore_file | ||
|
||
- name: Restore firewall state from a file | ||
community.general.iptables_state: | ||
state: restored | ||
path: /etc/iptables-restore.apply | ||
noflush: false | ||
async: "{{ ansible_timeout }}" | ||
poll: 0 | ||
when: iptables_restore_file.changed # noqa: no-handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
*filter | ||
:INPUT DROP [0:0] | ||
:FORWARD ACCEPT [0:0] | ||
:OUTPUT ACCEPT [0:0] | ||
:VEGATCP - [0:0] | ||
:VEGAUDP - [0:0] | ||
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT | ||
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | ||
-A INPUT -p udp -m udp --dport 53 -j ACCEPT | ||
-A INPUT -i lo -j ACCEPT | ||
-A INPUT -p tcp -j VEGATCP | ||
-A INPUT -p tcp -j VEGAUDP | ||
|
||
{% for port in firewall_open_tcp %} | ||
-A VEGATCP -p tcp -m tcp --dport {{ port|int }} -j ACCEPT | ||
{% endfor %} | ||
|
||
{% for port in firewall_open_udp %} | ||
-A VEGAUDP -p udp -m udp --dport {{ port|int }} -j ACCEPT | ||
{% endfor %} | ||
COMMIT |
File renamed without changes.