forked from hjoest/docker-netextender
-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
30 lines (24 loc) · 876 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
for v in 'VPN_USER' 'VPN_PASS' 'VPN_DOMAIN' 'VPN_SERVER' 'VPN_RDPIP'; do
if test -z $(eval "echo \$$v"); then
echo "Missing env variable $v" >&2
exit 1
fi
done
iptables -F
iptables -t nat -A PREROUTING -p tcp --dport 3380 -j DNAT --to-destination ${VPN_RDPIP}:3389
iptables -t nat -A POSTROUTING -j MASQUERADE
# Setup masquerade, to allow using the container as a gateway
for iface in $(ip a | grep eth | grep inet | awk '{print $2}'); do
iptables -t nat -A POSTROUTING -s "$iface" -j MASQUERADE
done
# Run the following script that will detect unwanted default routing
# on the VPN device. In case there will be any the script deletes it.
/gateway-fix.sh &
# Start VPN (in a loop).
while [ true ]; do
echo "------------ VPN Starts ------------"
/usr/bin/netextender
echo "------------ VPN exited ------------"
sleep 10
done