Alan Orth
d7c34a30a3
This configures the recommended DROP, EDROP, and DROPv6 lists from Spamhaus as ipsets in firewalld. First we copy an empty placeholder ipset to seed firewalld, then we use a shell script to download the real lists and activate them. The same shell script is run daily as a service (update-spamhaus-lists.service) by a systemd timer. I am strictly avoiding any direct ipset commands here because I want to make sure that this works on older hosts where ipsets is used as well as newer hosts that have moved to nftables such as Ubuntu 20.04. So far I have tested this on Ubuntu 16.04, 18.04, and 20.04, but ev- entually I need to abstract the tasks and run them on CentOS 7+ as well. See: https://www.spamhaus.org/drop/
82 lines
2.0 KiB
Django/Jinja
82 lines
2.0 KiB
Django/Jinja
<zone>
|
|
<short>Public</short>
|
|
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
|
|
<interface name="{{ ansible_default_ipv4.interface }}"/>
|
|
|
|
{# ssh rules #}
|
|
<rule family="ipv4">
|
|
<source address="0.0.0.0/0"/>
|
|
<port protocol="tcp" port="22"/>
|
|
<accept/>
|
|
</rule>
|
|
|
|
{# ipv6 ssh rules #}
|
|
<rule family="ipv6">
|
|
<source address="::/0"/>
|
|
<port protocol="tcp" port="22"/>
|
|
<accept/>
|
|
</rule>
|
|
|
|
{# web rules #}
|
|
<rule family="ipv4">
|
|
<source address="0.0.0.0/0"/>
|
|
<port protocol="tcp" port="80"/>
|
|
<accept/>
|
|
</rule>
|
|
|
|
{# ipv6 web rules #}
|
|
<rule family="ipv6">
|
|
<source address="::/0"/>
|
|
<port protocol="tcp" port="80"/>
|
|
<accept/>
|
|
</rule>
|
|
|
|
{# munin rules #}
|
|
{% if munin_master_host is defined %}
|
|
<rule family="ipv4">
|
|
<source address="{{ ghetto_ipsets[munin_master_host].src }}"/>
|
|
<port protocol="tcp" port="{{ munin_node_port }}"/>
|
|
<accept/>
|
|
</rule>
|
|
{% endif %}
|
|
|
|
{# extra rules #}
|
|
{% if extra_iptables_rules is defined %}
|
|
{% for rule in extra_iptables_rules %}
|
|
<rule family="ipv4">
|
|
<source address="{{ ghetto_ipsets[rule.acl].src }}"/>
|
|
<port protocol="{{ rule.protocol }}" port="{{ rule.port }}"/>
|
|
<accept/>
|
|
</rule>
|
|
|
|
{# ipv6 extra rules #}
|
|
{% if ghetto_ipsets[rule.acl].ipv6src is defined %}
|
|
<rule family="ipv6">
|
|
<source address="{{ ghetto_ipsets[rule.acl].ipv6src }}"/>
|
|
<port protocol="{{ rule.protocol }}" port="{{ rule.port }}"/>
|
|
<accept/>
|
|
</rule>
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
<rule>
|
|
<source ipset="abusers-ipv4"/>
|
|
<drop/>
|
|
</rule>
|
|
<rule>
|
|
<source ipset="abusers-ipv6"/>
|
|
<drop/>
|
|
</rule>
|
|
<rule>
|
|
<source ipset="spamhaus-ipv4"/>
|
|
<drop/>
|
|
</rule>
|
|
<rule>
|
|
<source ipset="spamhaus-ipv6"/>
|
|
<drop/>
|
|
</rule>
|
|
|
|
</zone>
|