From f314d9d35a91996e0d6b1cd92900c669ebc4d50f Mon Sep 17 00:00:00 2001 From: holzi1005 Date: Tue, 10 Dec 2024 13:03:26 +0100 Subject: [PATCH 1/2] Add cloud-init/10-network-init.sh --- cloud-init/10-network-init.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 cloud-init/10-network-init.sh diff --git a/cloud-init/10-network-init.sh b/cloud-init/10-network-init.sh new file mode 100644 index 0000000..7a693aa --- /dev/null +++ b/cloud-init/10-network-init.sh @@ -0,0 +1,3 @@ +#!/bin/bash + + -- 2.39.5 From 5903ca453d985e5916b104d956c07cd765bc59b2 Mon Sep 17 00:00:00 2001 From: holzi1005 Date: Tue, 10 Dec 2024 13:06:49 +0100 Subject: [PATCH 2/2] Update cloud-init/10-network-init.sh --- cloud-init/10-network-init.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cloud-init/10-network-init.sh b/cloud-init/10-network-init.sh index 7a693aa..edd8e4b 100644 --- a/cloud-init/10-network-init.sh +++ b/cloud-init/10-network-init.sh @@ -1,3 +1,23 @@ #!/bin/bash +VLAN=$1 +IP=$2 +GATEWAY=$3 +rm /etc/network/interfaces.d/* + +echo "source /etc/network/interfaces.d/*" > /etc/network/interfaces +echo "" >> /etc/network/interfaces +echo "auto lo" >> /etc/network/interfaces +echo "iface lo inet loopback" >> /etc/network/interfaces + +echo "auto eth1" > /etc/network/interfaces.d/ifcfg-eth1 +echo "iface eth1 inet static" >> /etc/network/interfaces.d/ifcfg-eth1 +echo " address 255.255.255.255/32" >> /etc/network/interfaces.d/ifcfg-eth1 + +echo "auto eth1.$VLAN" > /etc/network/interfaces.d/ifcfg-eth1.$VLAN +echo "iface eth1.$VLAN inet static" >> /etc/network/interfaces.d/ifcfg-eth1.$VLAN +echo " address $IP" >> /etc/network/interfaces.d/ifcfg-eth1.$VLAN +echo " gateway $GATEWAY" >> /etc/network/interfaces.d/ifcfg-eth1.$VLAN + +service networking restart \ No newline at end of file -- 2.39.5