diff --git a/local.md b/local.md new file mode 100644 index 0000000..c6428ad --- /dev/null +++ b/local.md @@ -0,0 +1,77 @@ +``` +VPC_NAME = vpc-000000 +SUBNET_NAME = subnet-000000 +SUBNET_ID = 000000 +TAP_ID = 0 +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" + + +brctl addif "br-000000" "eno1" + +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" + +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 up dev "tap0" + +VENDOR_DATA=$( +cat < "/opt/metadata/vpc-000000_192.168.14.131-8081.conf" +{ + "meta-data": "instance-id: vpc-000000\nlocal-hostname: test-vm\n", + "user-data": "#!/bin/sh\npasswd -d root\n", + "network-config": "version: 2\nethernets:\n eth0:\n dhcp4: true\n", + "vendor-data": "${VENDOR_DATA}" +} +END +systemctl status "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 \ + -cpu host \ + -m 1024 \ + -smp 1 \ + -serial "unix:/tmp/vm-3.sock,server,nowait" \ + -monitor "unix:/tmp/vm-3.mon-sock,server,nowait" \ + -qmp "unix:/tmp/vm-3.qmp-sock,server,nowait" \ + -display "none" \ + -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