bundles/wireguard: send pings over vpn, if pppd reconnects

This commit is contained in:
Franzi 2020-11-27 03:09:37 +01:00
parent c1885e20b6
commit 014b37082c
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 19 additions and 0 deletions

View 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

View file

@ -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',
}