new image structure for cisco-vpn and related scripts
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
This commit is contained in:
55
apps/rego-tunnel/shared/fix-netplan-ens3.sh
Normal file
55
apps/rego-tunnel/shared/fix-netplan-ens3.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/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 <<EOF
|
||||
network:
|
||||
version: 2
|
||||
ethernets:
|
||||
lan0:
|
||||
match:
|
||||
macaddress: ${MAC}
|
||||
set-name: ens3
|
||||
dhcp4: false
|
||||
addresses:
|
||||
- ${IP_CIDR}
|
||||
routes:
|
||||
- to: default
|
||||
via: ${GW}
|
||||
nameservers:
|
||||
addresses:
|
||||
- ${DNS1}
|
||||
- ${DNS2}
|
||||
EOF
|
||||
|
||||
chmod 600 /etc/netplan/*.yaml 2>/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
|
||||
Reference in New Issue
Block a user