mirror of
https://github.com/triffid/pia-wg.git
synced 2026-04-05 08:54:08 -04:00
Fix trying to edit routing tables even in config-only mode
This commit is contained in:
39
pia-wg.sh
39
pia-wg.sh
@@ -237,27 +237,30 @@ if [ -z "$WG_HOST$WG_PORT" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! ip route show table "$HARDWARE_ROUTE_TABLE" 2>/dev/null | grep -q .
|
if [ -z "$OPT_CONFIGONLY" ]
|
||||||
then
|
then
|
||||||
ROUTES_ADD=$(
|
if ! ip route show table "$HARDWARE_ROUTE_TABLE" 2>/dev/null | grep -q .
|
||||||
for IF in $(ip link show | grep -B1 'link/ether' | grep '^[0-9]' | cut -d: -f2)
|
|
||||||
do
|
|
||||||
ip route show | grep "dev $IF" | sed -e 's/linkdown//' | sed -e "s/^/ip route add table $HARDWARE_ROUTE_TABLE /"
|
|
||||||
done
|
|
||||||
)
|
|
||||||
if [ "$EUID" -eq 0 ]
|
|
||||||
then
|
then
|
||||||
sh <<< "$ROUTES_ADD"
|
ROUTES_ADD=$(
|
||||||
else
|
for IF in $(ip link show | grep -B1 'link/ether' | grep '^[0-9]' | cut -d: -f2)
|
||||||
echo "Build a routing table with only hardware links to stop wireguard packets going back through the VPN:"
|
do
|
||||||
echo sudo sh '<<<' "$ROUTES_ADD"
|
ip route show | grep "dev $IF" | sed -e 's/linkdown//' | sed -e "s/^/ip route add table $HARDWARE_ROUTE_TABLE /"
|
||||||
sudo sh <<< "$ROUTES_ADD"
|
done
|
||||||
|
)
|
||||||
|
if [ "$EUID" -eq 0 ]
|
||||||
|
then
|
||||||
|
sh <<< "$ROUTES_ADD"
|
||||||
|
else
|
||||||
|
echo "Build a routing table with only hardware links to stop wireguard packets going back through the VPN:"
|
||||||
|
echo sudo sh '<<<' "$ROUTES_ADD"
|
||||||
|
sudo sh <<< "$ROUTES_ADD"
|
||||||
|
fi
|
||||||
|
echo "Table $HARDWARE_ROUTE_TABLE (hardware network links) now contains:"
|
||||||
|
ip route show table "$HARDWARE_ROUTE_TABLE" | sed -e "s/^/${TAB}/"
|
||||||
|
echo
|
||||||
|
echo "${BOLD}*** PLEASE NOTE: if this table isn't updated by your network post-connect hooks, your connection cannot remain up if your network links change${NORMAL}"
|
||||||
|
echo "Managing such hooks is beyond the scope of this script"
|
||||||
fi
|
fi
|
||||||
echo "Table $HARDWARE_ROUTE_TABLE (hardware network links) now contains:"
|
|
||||||
ip route show table "$HARDWARE_ROUTE_TABLE" | sed -e "s/^/${TAB}/"
|
|
||||||
echo
|
|
||||||
echo "${BOLD}*** PLEASE NOTE: if this table isn't updated by your network post-connect hooks, your connection cannot remain up if your network links change${NORMAL}"
|
|
||||||
echo "Managing such hooks is beyond the scope of this script"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -r "$REMOTEINFO" ]
|
if ! [ -r "$REMOTEINFO" ]
|
||||||
|
|||||||
Reference in New Issue
Block a user