From ecf9298fc95f01c472af06f2016121a212bba3c0 Mon Sep 17 00:00:00 2001 From: GnomeZworc Date: Sun, 7 Dec 2025 19:54:33 +0100 Subject: [PATCH] update local.sh data Signed-off-by: GnomeZworc --- local.md => local.sh | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) rename local.md => local.sh (70%) diff --git a/local.md b/local.sh similarity index 70% rename from local.md rename to local.sh index c6428ad..88b808e 100644 --- a/local.md +++ b/local.sh @@ -1,4 +1,5 @@ -``` +#!/bin/bash + VPC_NAME = vpc-000000 SUBNET_NAME = subnet-000000 SUBNET_ID = 000000 @@ -7,28 +8,38 @@ DHCP = vpc-000000_br-000000.conf ip netns add vpc-000000 ip link add "veth-000000-ext" type veth peer name "veth-000000-int" netns "vpc-000000" -brctl addbr "br-000000" -brctl stp "br-000000" off -ip netns exec "vpc-000000" brctl addbr "br-000000" -ip netns exec "vpc-000000" brctl stp "br-000000" off -brctl addif "br-000000" "veth-000000-ext" -ip netns exec "vpc-000000" brctl addif "br-000000" "veth-000000-int" +sysctl -w net.ipv4.ip_forward=1 +ip netns exec vpc-000000 sysctl -w net.ipv4.ip_forward=1 - -brctl addif "br-000000" "eno1" +ip link add name "br-000000" type bridge +ip -n "vpc-000000" link add name "br-000000" type bridge +ip link set dev "br-000000" type bridge stp_state 0 +ip -n "vpc-000000" link set dev "br-000000" type bridge stp_state 0 ip link set up dev "veth-000000-ext" ip link set up dev "br-000000" ip -n "vpc-000000" link set up dev "veth-000000-int" ip -n "vpc-000000" link set up dev "br-000000" +ip link set "eno1" master "br-000000" +ip link set "veth-000000-ext" master "br-000000" +ip -n "vpc-000000" link set "veth-000000-int" master "br-000000" + + +ip a add 192.168.14.101/24 dev "br-000000" +ip route replace default via 192.168.14.1 dev "br-000000" +ip a del 192.168.14.101/24 dev eno1 + +pkill dhclient + ebtables -A FORWARD --out-interface "br-000000" -p IPv4 --ip-protocol udp --ip-source-port 67:68 --ip-destination-port 67:68 -j DROP ip -n "vpc-000000" tuntap add dev "tap0" mode tap -ip netns exec "vpc-000000" brctl addif "br-000000" "tap0" +ip -n "vpc-000000" link set "tap0" master "br-000000" ip -n "vpc-000000" link set up dev "tap0" +ip -n "vpc-000000" a add 192.168.14.131/24 dev "br-000000" VENDOR_DATA=$( cat < "/opt/metadata/vpc-000000_192.168.14.131-8081.conf" "vendor-data": "${VENDOR_DATA}" } END -systemctl status "metadata@vpc-000000_192.168.14.131-8081.service" +systemctl start "metadata@vpc-000000_192.168.14.131-8081.service" systemctl start "dnsmasq@vpc-000000_br-000000.service" - - ip netns exec "vpc-000000" iptables -t nat -A PREROUTING -s "192.168.14.151/32" -d "169.254.169.254/32" -p tcp -m tcp --dport 80 -j DNAT --to-destination "192.168.14.131:8081" ip netns exec "vpc-000000" qemu-system-x86_64 \ -enable-kvm \ @@ -73,5 +82,4 @@ ip netns exec "vpc-000000" qemu-system-x86_64 \ -drive "file=/disk/vm-3.qcow2,if=virtio" \ -netdev "tap,id=net0,ifname=tap0,script=no,downscript=no" \ -device "virtio-net-pci,netdev=net0,mac=00:22:33:00:00:01" \ - -daemonize -``` \ No newline at end of file + -daemonize \ No newline at end of file