mirror of https://github.com/dadevel/wg-netns
add extras
parent
da6e84552b
commit
cd0248f36a
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ $# -ne 3 ]; then
|
||||
echo 'usage: netns-publish PUBLIC_PORT NETNS_NAME NETNS_ADDRESS:NETNS_PORT'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec socat tcp-listen:"$1",reuseaddr,fork "exec:ip netns exec $2 socat stdio 'tcp-connect:$3',nofork"
|
@ -0,0 +1,8 @@
|
||||
# local wireguard interface name
|
||||
WG_INTERFACE=wg0
|
||||
# server wireguard public key
|
||||
WG_PEER=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
# server wireguard interface ip
|
||||
WG_GATEWAY=192.168.100.1
|
||||
# server dyndns domain
|
||||
WG_ENDPOINT=vpn.dyndns.example:51820
|
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if ! ping -q -c 1 -W "${WG_TIMEOUT:-5}" "$WG_GATEWAY"; then
|
||||
echo 'probe failed, resolving endpoint'
|
||||
wg set "$WG_INTERFACE" peer "$WG_PEER" endpoint "$WG_ENDPOINT"
|
||||
fi
|
@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=WireGuard Endpoint Resolver (%i)
|
||||
Wants=network-online.target nss-lookup.target
|
||||
After=network-online.target nss-lookup.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=%E/wireguard/%i.env
|
||||
Environment=WG_ENDPOINT_RESOLUTION_RETRIES=infinity
|
||||
ExecStart=/usr/local/lib/wg-resolve.sh
|
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Minutely WireGuard Endpoint Resolver
|
||||
|
||||
[Timer]
|
||||
OnCalendar=minutely
|
||||
AccuracySec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue