Update unraid-config.sh
This commit is contained in:
parent
0b57a4ada6
commit
696914e1c6
1 changed files with 24 additions and 7 deletions
|
@ -35,22 +35,39 @@ check_tailscale() {
|
|||
fix_routing() {
|
||||
echo -e "${YELLOW}Fixing routing table...${NC}"
|
||||
|
||||
# Delete Tailscale's default route if it exists
|
||||
# Delete any conflicting default routes
|
||||
ip route del default 2>/dev/null
|
||||
ip route del 0.0.0.0/0 dev tailscale1 2>/dev/null
|
||||
ip route del 0.0.0.0/0 dev wg0 2>/dev/null
|
||||
|
||||
# Ensure br0 is the default route
|
||||
# Get default gateway from br0
|
||||
local DEFAULT_GATEWAY=$(ip route | grep br0 | grep default | awk '{print $3}')
|
||||
|
||||
# Set up main routing
|
||||
ip route add default via $DEFAULT_GATEWAY dev br0
|
||||
|
||||
# Add specific route for VPS through Tailscale
|
||||
local TAILSCALE_NET=$(ip route | grep tailscale1 | awk '{print $1}')
|
||||
ip route add $VPS_IP via $TAILSCALE_NET dev tailscale1
|
||||
# Add specific route only for game traffic to VPS through Tailscale
|
||||
ip route add $VPS_IP via $(ip route | grep tailscale1 | awk '{print $1}') dev tailscale1
|
||||
|
||||
# Save current routing config
|
||||
# Ensure WireGuard routes are preserved
|
||||
if ip link show wg0 >/dev/null 2>&1; then
|
||||
# Get WireGuard IP and add its routes back
|
||||
local WG_IP=$(ip -4 addr show wg0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
|
||||
if [ ! -z "$WG_IP" ]; then
|
||||
ip route add $WG_IP dev wg0 scope link
|
||||
fi
|
||||
fi
|
||||
|
||||
# Save the routing configuration
|
||||
echo "#!/bin/bash" > /boot/config/routing.sh
|
||||
echo "ip route del default 2>/dev/null" >> /boot/config/routing.sh
|
||||
echo "ip route del 0.0.0.0/0 dev tailscale1 2>/dev/null" >> /boot/config/routing.sh
|
||||
echo "ip route del 0.0.0.0/0 dev wg0 2>/dev/null" >> /boot/config/routing.sh
|
||||
echo "ip route add default via $DEFAULT_GATEWAY dev br0" >> /boot/config/routing.sh
|
||||
echo "ip route add $VPS_IP via $TAILSCALE_NET dev tailscale1" >> /boot/config/routing.sh
|
||||
echo "ip route add $VPS_IP via \$(ip route | grep tailscale1 | awk '{print \$1}') dev tailscale1" >> /boot/config/routing.sh
|
||||
if [ ! -z "$WG_IP" ]; then
|
||||
echo "ip route add $WG_IP dev wg0 scope link" >> /boot/config/routing.sh
|
||||
fi
|
||||
chmod +x /boot/config/routing.sh
|
||||
|
||||
echo -e "${GREEN}Routing table fixed successfully${NC}"
|
||||
|
|
Loading…
Reference in a new issue