aboutsummaryrefslogtreecommitdiff
path: root/ansible/roles/lxc-host/tasks/ufw-nat.yml
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/lxc-host/tasks/ufw-nat.yml')
-rw-r--r--ansible/roles/lxc-host/tasks/ufw-nat.yml21
1 files changed, 21 insertions, 0 deletions
diff --git a/ansible/roles/lxc-host/tasks/ufw-nat.yml b/ansible/roles/lxc-host/tasks/ufw-nat.yml
new file mode 100644
index 0000000..219b70b
--- /dev/null
+++ b/ansible/roles/lxc-host/tasks/ufw-nat.yml
@@ -0,0 +1,21 @@
+- name:
+ tags:
+ - lxc-host
+ - lxc-host-network
+ block:
+ - name: Enable NAT configuration through UFW
+ become: yes
+ notify: reload ufw
+ blockinfile:
+ path: /etc/ufw/before.rules
+ insertbefore: "# Don't delete these required lines, otherwise there will be errors"
+ block: |
+ # NAT table rules
+ *nat
+ :POSTROUTING ACCEPT [0:0]
+
+ # Forward traffic through eth0 - Change to match you out-interface
+ -A POSTROUTING -s {{ internal_if.ipv4.address }}/{{ internal_if.ipv4.netmask }} -o {{ lxc_host__hardware_if }} -j MASQUERADE
+
+ # don't delete the 'COMMIT' line or these nat table rules won't be processed
+ COMMIT