rc.wireguard: fix regression bug

Connection to Internet is interrupted at startup and Wireguard docker VPN is configured
This commit is contained in:
bergware
2023-08-16 02:45:47 +02:00
parent 2d14853a95
commit 6021269ca6
+9
View File
@@ -57,6 +57,15 @@ start() {
echo "wg-quick up $WG (autostart)" >>$LOG
cat $TMP >>$LOG
echo >>$LOG
# WG tunnel for docker container?
if grep -qm1 '^TYPE:1="8"' $WIREGUARD/$WG.cfg; then
# update routing table for WG tunnels used by containers
TABLE=$(grep -Pom1 'fwmark \K[\d]+' $TMP)
ROUTE=$(grep -Pom1 '^Address=\K.+$' $WIREGUARD/$WG.conf)
sleep 1
ip -4 route flush table $TABLE
ip -4 route add $ROUTE dev $WG table $TABLE
fi
fi
done
rm -f $TMP