Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add an alternative way to define the sysctl for UFW #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ufw:
- nf_conntrack_netbios_ns

sysctl:
sysctls:
net/ipv4/ip_forward: 1
net/ipv6/conf/default/forwarding: 1
net/ipv6/conf/all/forwarding: 1
forwarding: 1
rp_filter: 1
accept_source_route: 0
Expand Down
7 changes: 7 additions & 0 deletions ufw/files/default/ufw.sysctl.tmpl.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# File managed by Salt at <{{ source }}>.
# Your changes will be overwritten.
########################################################################
{%- set sysctls = ufw_sysctl.get('sysctls') %}
{%- set forwarding = ufw_sysctl.get('forwarding', 0) %}
{%- set rp_filter = ufw_sysctl.get('rp_filter', 1) %}
{%- set accept_source_route = ufw_sysctl.get('accept_source_route', 0) %}
Expand All @@ -18,6 +19,11 @@
# Configuration file for setting network variables. Please note these settings
# override /etc/sysctl.conf. If you prefer to use /etc/sysctl.conf, please
# adjust IPT_SYSCTL in /etc/default/ufw.
{%- if sysctls is not none %}
{%- for sysctl, value in sysctls.items() %}
{{ sysctl }}={{ value }}
{%- endfor %}
{%- else %}

# Uncomment this to allow this host to route packets between interfaces
net/ipv4/ip_forward={{ forwarding }}
Expand Down Expand Up @@ -70,3 +76,4 @@ net/ipv6/conf/all/autoconf={{ ipv6_autoconf }}
# Uncomment this to enable ipv6 privacy addressing
net/ipv6/conf/default/use_tempaddr={{ use_tempaddr }}
net/ipv6/conf/all/use_tempaddr={{ use_tempaddr }}
{% endif %}