Commit 5737317 1 parent 88eaf30 commit 5737317 Copy full SHA for 5737317
File tree 5 files changed +18
-3
lines changed
5 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ strongswan_network: 10.19.48.0/24
32
32
strongswan_network_ipv6: ' fd9d:bc11:4020::/48'
33
33
34
34
# Deploy WireGuard
35
+ # WireGuard will listen on 51820/UDP. You might need to change to another port
36
+ # if your network blocks this one. Be aware that 53/UDP (DNS) is blocked on some
37
+ # mobile data networks.
35
38
wireguard_enabled: true
36
39
wireguard_port: 51820
37
40
# If you're behind NAT or a firewall and you want to receive incoming connections long after network traffic has gone silent.
Original file line number Diff line number Diff line change 1
1
{% set subnets = ([strongswan_network ] if ipsec_enabled else []) + ([wireguard_network_ipv 4] if wireguard_enabled else []) %}
2
- {% set ports = (['500' , '4500' ] if ipsec_enabled else []) + ([wireguard_port ] if wireguard_enabled else []) %}
2
+ {% 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 []) %}
3
3
4
4
#### The mangle table
5
5
# This table allows us to modify packet headers
@@ -29,6 +29,11 @@ COMMIT
29
29
:PREROUTING ACCEPT [0:0]
30
30
:POSTROUTING ACCEPT [0:0]
31
31
32
+ {% if wireguard_enabled and wireguard_port |int == wireguard_port_avoid |int %}
33
+ # Handle the special case of allowing access to WireGuard over an already used
34
+ # port like 53
35
+ -A PREROUTING --in-interface {{ ansible_default_ipv4['interface'] }} -p udp --dport {{ wireguard_port_avoid }} -j REDIRECT --to-port {{ wireguard_port_actual }}
36
+ {% endif %}
32
37
# Allow traffic from the VPN network to the outside world, and replies
33
38
-A POSTROUTING -s {{ subnets|join(',') }} -m policy --pol none --dir out -j MASQUERADE
34
39
Original file line number Diff line number Diff line change 1
1
{% set subnets = ([strongswan_network_ipv 6] if ipsec_enabled else []) + ([wireguard_network_ipv 6] if wireguard_enabled else []) %}
2
- {% set ports = (['500' , '4500' ] if ipsec_enabled else []) + ([wireguard_port ] if wireguard_enabled else []) %}
2
+ {% 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 []) %}
3
3
4
4
#### The mangle table
5
5
# This table allows us to modify packet headers
@@ -28,6 +28,11 @@ COMMIT
28
28
:PREROUTING ACCEPT [0:0]
29
29
:POSTROUTING ACCEPT [0:0]
30
30
31
+ {% if wireguard_enabled and wireguard_port |int == wireguard_port_avoid |int %}
32
+ # Handle the special case of allowing access to WireGuard over an already used
33
+ # port like 53
34
+ -A PREROUTING --in-interface {{ ansible_default_ipv6['interface'] }} -p udp --dport {{ wireguard_port_avoid }} -j REDIRECT --to-port {{ wireguard_port_actual }}
35
+ {% endif %}
31
36
# Allow traffic from the VPN network to the outside world, and replies
32
37
-A POSTROUTING -s {{ subnets|join(',') }} -m policy --pol none --dir out -j MASQUERADE
33
38
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ wireguard_PersistentKeepalive: 0
3
3
wireguard_config_path : " configs/{{ IP_subject_alt_name }}/wireguard/"
4
4
wireguard_pki_path : " {{ wireguard_config_path }}/.pki/"
5
5
wireguard_interface : wg0
6
+ wireguard_port_avoid : 53
7
+ wireguard_port_actual : 51820
6
8
keys_clean_all : false
7
9
wireguard_dns_servers : >-
8
10
{% if algo_dns_adblocking|default(false)|bool or dns_encryption|default(false)|bool %}
Original file line number Diff line number Diff line change 1
1
[Interface]
2
2
Address = {{ wireguard_server_ip }}
3
- ListenPort = {{ wireguard_port }}
3
+ ListenPort = {{ wireguard_port_actual if wireguard_port|int == wireguard_port_avoid|int else wireguard_port }}
4
4
PrivateKey = {{ lookup('file', wireguard_pki_path + '/private/' + IP_subject_alt_name) }}
5
5
SaveConfig = false
6
6
You can’t perform that action at this time.
0 commit comments