Some corrections for Activates link local for both ports, removes fallback IP.

This commit is contained in:
pober
2026-03-03 15:35:13 +01:00
committed by pstruebi
parent c82f375539
commit 540d8503ac

View File

@@ -6,15 +6,17 @@ set -e
# Ensure static link local is activated (for direct laptop connection)
# Enable link-local for all wired ethernet connections
for conn in $(nmcli -t -f NAME,TYPE connection show | grep "ethernet" | cut -d: -f1); do
echo "Enabling IPv4 link-local for connection: $conn"
sudo nmcli connection modify "$conn" ipv4.link-local enabled 2>/dev/null || echo "Failed to modify $conn"
sudo nmcli connection up "$conn" 2>/dev/null || echo "Failed to bring up $conn"
done
while IFS=: read -r name type; do
if [[ "$type" == *"ethernet"* ]]; then
echo "Enabling IPv4 link-local for connection: $name"
sudo nmcli connection modify "$name" ipv4.link-local enabled 2>/dev/null || echo "Failed to modify $name"
sudo nmcli connection up "$name" 2>/dev/null || echo "Failed to bring up $name"
fi
done < <(nmcli -t -f NAME,TYPE connection show)
# Configure Avahi to prefer DHCP address over static fallback for mDNS
# Get the DHCP-assigned IP (first non-localhost, non-192.168.42.10 IP)
DHCP_IP=$(ip -4 addr show eth0 2>/dev/null | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '^127\.' | grep -v "$(echo $FALLBACK_IP | sed 's/\/24//')" | head -n1)
DHCP_IP=$(ip -4 addr show eth0 2>/dev/null | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | grep -v '^127\.' | grep -v '^169\.254\.' | head -n1)
HOSTNAME=$(hostname)
if [ -n "$DHCP_IP" ]; then