Files
proxmox/scripts/archive/consolidated/fix/fix-vlan11-gateway.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

162 lines
4.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Load IP configuration
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
# Fix VLAN 11 Gateway Configuration
# Usage: sudo ./scripts/unifi/fix-vlan11-gateway.sh
set -e
INTERFACE="eth0"
TARGET_IP="192.168.11.4"
TARGET_GATEWAY="${NETWORK_GATEWAY:-192.168.11.1}"
ALTERNATIVE_GATEWAY="192.168.0.1"
echo "🔧 Fixing VLAN 11 Gateway Configuration"
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "❌ Please run as root (use sudo)"
exit 1
fi
# Check current IP
CURRENT_IP=$(ip -4 addr show $INTERFACE | grep -oP 'inet \K[\d.]+' | head -1)
CURRENT_GATEWAY=$(ip route show | grep default | awk '{print $3}' | head -1)
echo "📋 Current Configuration:"
echo " IP Address: $CURRENT_IP"
echo " Gateway: $CURRENT_GATEWAY"
echo ""
# Test gateway connectivity
echo "🧪 Testing Gateway Connectivity..."
if ping -c 1 -W 2 $TARGET_GATEWAY >/dev/null 2>&1; then
echo " ✅ Gateway $TARGET_GATEWAY is reachable"
echo " No changes needed"
exit 0
else
echo " ❌ Gateway $TARGET_GATEWAY is not reachable"
fi
# Test alternative gateway
if ping -c 1 -W 2 $ALTERNATIVE_GATEWAY >/dev/null 2>&1; then
echo " ✅ Alternative gateway $ALTERNATIVE_GATEWAY is reachable"
echo " ⚠️ UDM Pro might be accessible via Default network gateway"
USE_ALTERNATIVE=true
else
echo " ❌ Alternative gateway $ALTERNATIVE_GATEWAY is also not reachable"
USE_ALTERNATIVE=false
fi
# Find netplan config
NETPLAN_FILE=$(ls /etc/netplan/*.yaml 2>/dev/null | head -1)
if [ -z "$NETPLAN_FILE" ]; then
echo "❌ No netplan config file found"
exit 1
fi
echo ""
echo "📋 Found netplan config: $NETPLAN_FILE"
echo ""
# Backup
BACKUP_FILE="${NETPLAN_FILE}.backup.$(date +%Y%m%d_%H%M%S)"
cp "$NETPLAN_FILE" "$BACKUP_FILE"
echo "✅ Backup created: $BACKUP_FILE"
echo ""
# Update gateway
if [ "$USE_ALTERNATIVE" = true ]; then
echo "🔄 Updating gateway to $ALTERNATIVE_GATEWAY (UDM Pro on Default network)..."
FINAL_GATEWAY=$ALTERNATIVE_GATEWAY
else
echo "🔄 Updating gateway to $TARGET_GATEWAY (VLAN 11 gateway)..."
FINAL_GATEWAY=$TARGET_GATEWAY
fi
# Update netplan using Python
python3 << EOF
import yaml
import sys
# Read current config
with open("$NETPLAN_FILE", 'r') as f:
config = yaml.safe_load(f)
# Update gateway
if 'network' not in config:
config['network'] = {}
if 'ethernets' not in config['network']:
config['network']['ethernets'] = {}
if '$INTERFACE' not in config['network']['ethernets']:
config['network']['ethernets']['$INTERFACE'] = {}
# Update gateway
config['network']['ethernets']['$INTERFACE']['gateway4'] = '$FINAL_GATEWAY'
# Write updated config
with open("$NETPLAN_FILE", 'w') as f:
yaml.dump(config, f, default_flow_style=False, sort_keys=False)
print("✅ Gateway updated to $FINAL_GATEWAY")
EOF
if [ $? -ne 0 ]; then
echo "❌ Failed to update config. Restoring backup..."
cp "$BACKUP_FILE" "$NETPLAN_FILE"
exit 1
fi
echo ""
echo "📋 Updated configuration:"
cat "$NETPLAN_FILE"
echo ""
# Apply changes
echo "🔄 Applying netplan configuration..."
if netplan try --timeout 5 >/dev/null 2>&1; then
netplan apply
echo "✅ Configuration applied"
else
echo "⚠️ Validation failed. Restoring backup..."
cp "$BACKUP_FILE" "$NETPLAN_FILE"
netplan apply
exit 1
fi
# Wait for network
sleep 3
# Verify
echo ""
echo "🔍 Verifying new gateway..."
NEW_GATEWAY=$(ip route show | grep default | awk '{print $3}' | head -1)
echo " New Gateway: $NEW_GATEWAY"
# Test connectivity
echo ""
echo "🧪 Testing gateway connectivity..."
if ping -c 2 -W 2 $NEW_GATEWAY >/dev/null 2>&1; then
echo " ✅ Gateway $NEW_GATEWAY is now reachable!"
else
echo " ⚠️ Gateway $NEW_GATEWAY is still not reachable"
echo " This might be normal if UDM Pro uses a different gateway IP"
fi
echo ""
echo "✅ Gateway configuration updated!"
echo ""
echo "💡 Note: If gateway is still not reachable, UDM Pro might:"
echo " • Use a different IP for VLAN 11 gateway"
echo " • Route through Default network (192.168.0.1)"
echo " • Require additional routing configuration"