Skip to content

Commit

Permalink
Allow client-to-client to work with SNAT and masquerade (#179)
Browse files Browse the repository at this point in the history
Co-authored-by: Kyle Lexmond <[email protected]>
  • Loading branch information
makkrnic and kyl191 authored Dec 22, 2024
1 parent 09aeb80 commit a1ca87f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions tasks/iptables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
table: nat
chain: POSTROUTING
source: "{{ openvpn_server_network }}/24"
destination: "! {{ openvpn_server_network }}/24"
to_source: "{{ ansible_default_ipv4.address }}"
jump: SNAT
action: insert
Expand All @@ -77,6 +78,7 @@
table: nat
chain: POSTROUTING
source: "{{ openvpn_server_network }}/24"
destination: "! {{ openvpn_server_network }}/24"
jump: MASQUERADE
action: insert
comment: "Perform NAT readdressing"
Expand Down
4 changes: 2 additions & 2 deletions tasks/ufw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# OpenVPN config
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s {{ openvpn_server_network }}/24 -j SNAT --to-source {{ openvpn_lan_source_ip }}
-A POSTROUTING -s {{ openvpn_server_network }}/24 ! -d {{ openvpn_server_network }}/24 -j SNAT --to-source {{ openvpn_lan_source_ip }}
COMMIT
when: not openvpn_masquerade_not_snat
notify:
Expand All @@ -54,7 +54,7 @@
# OpenVPN config
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -s {{ openvpn_server_network }}/24 -j MASQUERADE
-A POSTROUTING -s {{ openvpn_server_network }}/24 ! -d {{ openvpn_server_network }}/24 -j MASQUERADE
COMMIT
when: openvpn_masquerade_not_snat
notify:
Expand Down

0 comments on commit a1ca87f

Please sign in to comment.