Files
proxmox/scripts/fix-wsl-ip.sh
defiQUG bea1903ac9
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
Sync all local changes: docs, config, scripts, submodule refs, verification evidence
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-21 15:46:06 -08:00

65 lines
1.8 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Fix WSL IP address from 192.168.11.4 to 192.168.11.23
# This script removes the old IP and adds the correct one
set -e
OLD_IP="192.168.11.4"
NEW_IP="192.168.11.23"
INTERFACE="eth0"
echo "🔧 Fixing WSL IP Address Configuration"
echo " Changing from $OLD_IP to $NEW_IP"
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "❌ This script must be run with sudo"
echo " Usage: sudo $0"
exit 1
fi
# Remove old IP if it exists
if ip addr show $INTERFACE | grep -q "$OLD_IP"; then
echo " Removing old IP address: $OLD_IP"
ip addr del $OLD_IP/24 dev $INTERFACE 2>/dev/null || true
echo " ✅ Old IP removed"
else
echo " Old IP ($OLD_IP) not found, skipping removal"
fi
# Remove old route if it exists
if ip route show | grep -q "192.168.11.0/24.*src $OLD_IP"; then
echo " Removing old route"
ip route del 192.168.11.0/24 dev $INTERFACE src $OLD_IP 2>/dev/null || true
echo " ✅ Old route removed"
fi
# Add new IP if it doesn't exist
if ip addr show $INTERFACE | grep -q "$NEW_IP"; then
echo " New IP ($NEW_IP) already configured"
else
echo " Adding new IP address: $NEW_IP"
ip addr add $NEW_IP/24 dev $INTERFACE
echo " ✅ New IP added"
fi
# Add route if it doesn't exist
if ! ip route show | grep -q "192.168.11.0/24.*src $NEW_IP"; then
echo " Adding route for VLAN 11 network"
ip route add 192.168.11.0/24 dev $INTERFACE src $NEW_IP 2>/dev/null || true
echo " ✅ Route added"
else
echo " Route already exists"
fi
echo ""
echo "✅ IP Configuration Updated!"
echo ""
echo "📋 Current IP Addresses on $INTERFACE:"
ip addr show $INTERFACE | grep "inet " | sed 's/^/ /'
echo ""
echo "💡 Next step: Update ~/.bashrc to use $NEW_IP for persistence"
echo " Run: sed -i 's/$OLD_IP/$NEW_IP/g' ~/.bashrc"
echo ""