mirror of
https://github.com/trailofbits/algo.git
synced 2025-08-02 10:53:01 +02:00
Use a variable for the port to avoid
This commit is contained in:
parent
1eb96bec76
commit
d1ea4f2e35
4 changed files with 13 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
{% set subnets = ([strongswan_network] if ipsec_enabled else []) + ([wireguard_network_ipv4] if wireguard_enabled else []) %}
|
{% set subnets = ([strongswan_network] if ipsec_enabled else []) + ([wireguard_network_ipv4] if wireguard_enabled else []) %}
|
||||||
{% set ports = (['500', '4500'] if ipsec_enabled else []) + ([wireguard_port] if wireguard_enabled else []) + ([wireguard_port_alt] if wireguard_enabled and wireguard_port|int == 53 else []) %}
|
{% set ports = (['500', '4500'] if ipsec_enabled else []) + ([wireguard_port] if wireguard_enabled else []) + ([wireguard_port_actual] if wireguard_enabled and wireguard_port|int == wireguard_port_avoid|int else []) %}
|
||||||
|
|
||||||
#### The mangle table
|
#### The mangle table
|
||||||
# This table allows us to modify packet headers
|
# This table allows us to modify packet headers
|
||||||
|
@ -29,9 +29,10 @@ COMMIT
|
||||||
:PREROUTING ACCEPT [0:0]
|
:PREROUTING ACCEPT [0:0]
|
||||||
:POSTROUTING ACCEPT [0:0]
|
:POSTROUTING ACCEPT [0:0]
|
||||||
|
|
||||||
{% if wireguard_enabled and wireguard_port|int == 53 %}
|
{% if wireguard_enabled and wireguard_port|int == wireguard_port_avoid|int %}
|
||||||
# Handle the special case of allowing access to WireGuard over port 53
|
# Handle the special case of allowing access to WireGuard over an already used
|
||||||
-A PREROUTING --in-interface {{ ansible_default_ipv4['interface'] }} -p udp --dport 53 -j REDIRECT --to-port {{ wireguard_port_alt }}
|
# port like 53
|
||||||
|
-A PREROUTING --in-interface {{ ansible_default_ipv4['interface'] }} -p udp --dport {{ wireguard_port_avoid }} -j REDIRECT --to-port {{ wireguard_port_actual }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Allow traffic from the VPN network to the outside world, and replies
|
# Allow traffic from the VPN network to the outside world, and replies
|
||||||
-A POSTROUTING -s {{ subnets|join(',') }} -m policy --pol none --dir out -j MASQUERADE
|
-A POSTROUTING -s {{ subnets|join(',') }} -m policy --pol none --dir out -j MASQUERADE
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{% set subnets = ([strongswan_network_ipv6] if ipsec_enabled else []) + ([wireguard_network_ipv6] if wireguard_enabled else []) %}
|
{% set subnets = ([strongswan_network_ipv6] if ipsec_enabled else []) + ([wireguard_network_ipv6] if wireguard_enabled else []) %}
|
||||||
{% set ports = (['500', '4500'] if ipsec_enabled else []) + ([wireguard_port] if wireguard_enabled else []) + ([wireguard_port_alt] if wireguard_enabled and wireguard_port|int == 53 else []) %}
|
{% set ports = (['500', '4500'] if ipsec_enabled else []) + ([wireguard_port] if wireguard_enabled else []) + ([wireguard_port_actual] if wireguard_enabled and wireguard_port|int == wireguard_port_avoid|int else []) %}
|
||||||
|
|
||||||
#### The mangle table
|
#### The mangle table
|
||||||
# This table allows us to modify packet headers
|
# This table allows us to modify packet headers
|
||||||
|
@ -28,9 +28,10 @@ COMMIT
|
||||||
:PREROUTING ACCEPT [0:0]
|
:PREROUTING ACCEPT [0:0]
|
||||||
:POSTROUTING ACCEPT [0:0]
|
:POSTROUTING ACCEPT [0:0]
|
||||||
|
|
||||||
{% if wireguard_enabled and wireguard_port|int == 53 %}
|
{% if wireguard_enabled and wireguard_port|int == wireguard_port_avoid|int %}
|
||||||
# Handle the special case of allowing access to WireGuard over port 53
|
# Handle the special case of allowing access to WireGuard over an already used
|
||||||
-A PREROUTING --in-interface {{ ansible_default_ipv6['interface'] }} -p udp --dport 53 -j REDIRECT --to-port {{ wireguard_port_alt }}
|
# port like 53
|
||||||
|
-A PREROUTING --in-interface {{ ansible_default_ipv6['interface'] }} -p udp --dport {{ wireguard_port_avoid }} -j REDIRECT --to-port {{ wireguard_port_actual }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
# Allow traffic from the VPN network to the outside world, and replies
|
# Allow traffic from the VPN network to the outside world, and replies
|
||||||
-A POSTROUTING -s {{ subnets|join(',') }} -m policy --pol none --dir out -j MASQUERADE
|
-A POSTROUTING -s {{ subnets|join(',') }} -m policy --pol none --dir out -j MASQUERADE
|
||||||
|
|
|
@ -3,7 +3,8 @@ wireguard_PersistentKeepalive: 0
|
||||||
wireguard_config_path: "configs/{{ IP_subject_alt_name }}/wireguard/"
|
wireguard_config_path: "configs/{{ IP_subject_alt_name }}/wireguard/"
|
||||||
wireguard_pki_path: "{{ wireguard_config_path }}/.pki/"
|
wireguard_pki_path: "{{ wireguard_config_path }}/.pki/"
|
||||||
wireguard_interface: wg0
|
wireguard_interface: wg0
|
||||||
wireguard_port_alt: 51820
|
wireguard_port_avoid: 53
|
||||||
|
wireguard_port_actual: 51820
|
||||||
keys_clean_all: false
|
keys_clean_all: false
|
||||||
wireguard_dns_servers: >-
|
wireguard_dns_servers: >-
|
||||||
{% if algo_dns_adblocking|default(false)|bool or dns_encryption|default(false)|bool %}
|
{% if algo_dns_adblocking|default(false)|bool or dns_encryption|default(false)|bool %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[Interface]
|
[Interface]
|
||||||
Address = {{ wireguard_server_ip }}
|
Address = {{ wireguard_server_ip }}
|
||||||
ListenPort = {{ wireguard_port_alt if wireguard_port|int == 53 else wireguard_port }}
|
ListenPort = {{ wireguard_port_actual if wireguard_port|int == wireguard_port_avoid|int else wireguard_port }}
|
||||||
PrivateKey = {{ lookup('file', wireguard_pki_path + '/private/' + IP_subject_alt_name) }}
|
PrivateKey = {{ lookup('file', wireguard_pki_path + '/private/' + IP_subject_alt_name) }}
|
||||||
SaveConfig = false
|
SaveConfig = false
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue