bundles/wireguard: send pings over vpn, if pppd reconnects
This commit is contained in:
parent
c1885e20b6
commit
014b37082c
2 changed files with 19 additions and 0 deletions
12
bundles/wireguard/files/pppd-ip-up
Normal file
12
bundles/wireguard/files/pppd-ip-up
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# We need to send some traffic over the wireguard tunnel to make sure
|
||||
# it gets connected. Easiest way is to simply send some pings to the
|
||||
# other side.
|
||||
|
||||
% for peer, config in node.metadata.get('wireguard', {}).get('peers', {}).items():
|
||||
% for ip in sorted(config['ips']):
|
||||
# refresh connection to ${peer} ${ip}
|
||||
/usr/bin/ping -c 4 ${ip.split('/')[0] if '/' in ip else ip}
|
||||
% endfor
|
||||
% endfor
|
|
@ -27,3 +27,10 @@ files = {
|
|||
'mode': '0755',
|
||||
},
|
||||
}
|
||||
|
||||
if node.has_bundle('pppd'):
|
||||
files['/etc/ppp/ip-up.d/reconnect-wireguard'] = {
|
||||
'source': 'pppd-ip-up',
|
||||
'content_type': 'mako',
|
||||
'mode': '0755',
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue