gns3-registry/packer/debian/scripts/networking.sh

47 lines
1.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
set -ex
2023-06-12 21:09:20 +00:00
# add hostname into /etc/hosts
if [ -z "$(hostname -d)" ]; then
printf '127.0.1.1\t%s\n' "$(hostname)" >> /etc/hosts
else
printf '127.0.1.1\t%s\t%s\n' "$(hostname -f)" "$(hostname)" >> /etc/hosts
fi
# replace netplan and systemd-resolved by ifupdown and resolvconf
2023-06-12 21:09:20 +00:00
export DEBIAN_FRONTEND=noninteractive
apt-get update
2024-01-19 13:30:59 +00:00
apt-get -y upgrade
cp /etc/resolv.conf /etc/resolv.conf.orig
2023-06-12 21:09:20 +00:00
apt-get -y install --purge ifupdown resolvconf
cat /etc/resolv.conf.orig > /etc/resolv.conf
rm -f /etc/resolv.conf.orig
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
rm -rf /etc/netplan
apt-get -y autoremove --purge netplan.io
2023-06-12 21:09:20 +00:00
2022-11-16 18:03:31 +00:00
# replace cloud-init network configuration
cat > /etc/network/interfaces <<'EOF'
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# DHCP config for ens4
#auto ens4
#iface ens4 inet dhcp
# Static config for ens4
#auto ens4
#iface ens4 inet static
# address 192.168.1.100
# netmask 255.255.255.0
# gateway 192.168.1.1
# dns-nameservers 192.168.1.1
EOF
rm -f /etc/network/interfaces.d/50-cloud-init