Skip to content

Commit

Permalink
scripts: remove local default dev lo route in skip-vpn
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun committed Jan 14, 2024
1 parent 2c67888 commit 000b7eb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dot_bin/executable_skip-vpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ TABLE="${TABLE:-100}"
CGROUP="${CGROUP:-/user.slice/user-1000.slice/user@1000.service/app.slice/no-proxy.service}"

if [[ -z "$(ip rule list fwmark "$FWMARK" table "$TABLE")" ]]; then
ip rule add fwmark "$FWMARK" table "$TABLE"
ip rule add fwmark "$FWMARK" table "$TABLE"
fi
default_route_table="$(ip route show default)"
default_link="$(ip -j route show default | grep -E -o '"dev":\s*"([^"]*)"' | awk -F\" '{print $4}')"
ip route replace $default_route_table table "$TABLE"
# I don't know why this route exists by default.
if ! ip route delete local default dev lo scope host table "$TABLE"; then
:
fi

iptables -t mangle -I OUTPUT -m cgroup --path "$CGROUP" -j MARK --set-mark "$FWMARK"
iptables -t nat -A POSTROUTING -o "$default_link" -j MASQUERADE

0 comments on commit 000b7eb

Please sign in to comment.