#!/usr/bin/env bash set -euo pipefail MAC="52:54:00:12:34:56" IP_CIDR="100.100.0.2/24" GW="100.100.0.1" DNS1="8.8.8.8" DNS2="1.1.1.1" backup_dir="/etc/netplan/backup-$(date +%Y%m%d-%H%M%S)" mkdir -p "$backup_dir" # Back up all current netplan YAMLs cp -a /etc/netplan/*.yaml "$backup_dir"/ 2>/dev/null || true # Move any NetworkManager-generated netplan snippets out of the way if ls /etc/netplan/90-NM-*.yaml >/dev/null 2>&1; then mv /etc/netplan/90-NM-*.yaml "$backup_dir"/ || true fi cat > /etc/netplan/00-installer-config.yaml </dev/null || true netplan generate netplan apply sleep 2 echo "==== Interfaces (ens3/ens4) ====" ip -br a | grep -E '^(ens3|ens4)\b' || true echo "==== Routes ====" ip route | sed -n '1,10p' echo "==== Ping ====" ping -c 1 -W 2 1.1.1.1