update local.sh data
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
59860c54fc
commit
ecf9298fc9
1 changed files with 23 additions and 15 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
```
|
#!/bin/bash
|
||||||
|
|
||||||
VPC_NAME = vpc-000000
|
VPC_NAME = vpc-000000
|
||||||
SUBNET_NAME = subnet-000000
|
SUBNET_NAME = subnet-000000
|
||||||
SUBNET_ID = 000000
|
SUBNET_ID = 000000
|
||||||
|
|
@ -7,28 +8,38 @@ DHCP = vpc-000000_br-000000.conf
|
||||||
|
|
||||||
ip netns add vpc-000000
|
ip netns add vpc-000000
|
||||||
ip link add "veth-000000-ext" type veth peer name "veth-000000-int" netns "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"
|
sysctl -w net.ipv4.ip_forward=1
|
||||||
ip netns exec "vpc-000000" brctl addif "br-000000" "veth-000000-int"
|
ip netns exec vpc-000000 sysctl -w net.ipv4.ip_forward=1
|
||||||
|
|
||||||
|
ip link add name "br-000000" type bridge
|
||||||
brctl addif "br-000000" "eno1"
|
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 "veth-000000-ext"
|
||||||
ip link set up dev "br-000000"
|
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 "veth-000000-int"
|
||||||
ip -n "vpc-000000" link set up dev "br-000000"
|
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
|
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 -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" link set up dev "tap0"
|
||||||
|
ip -n "vpc-000000" a add 192.168.14.131/24 dev "br-000000"
|
||||||
|
|
||||||
VENDOR_DATA=$(
|
VENDOR_DATA=$(
|
||||||
cat <<END | sed -e ':a;N;$!ba;s/\n/\\n/g' | sed -e 's/"/\\"/g'
|
cat <<END | sed -e ':a;N;$!ba;s/\n/\\n/g' | sed -e 's/"/\\"/g'
|
||||||
|
|
@ -54,12 +65,10 @@ cat <<END > "/opt/metadata/vpc-000000_192.168.14.131-8081.conf"
|
||||||
"vendor-data": "${VENDOR_DATA}"
|
"vendor-data": "${VENDOR_DATA}"
|
||||||
}
|
}
|
||||||
END
|
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"
|
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" 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 \
|
ip netns exec "vpc-000000" qemu-system-x86_64 \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
|
|
@ -73,5 +82,4 @@ ip netns exec "vpc-000000" qemu-system-x86_64 \
|
||||||
-drive "file=/disk/vm-3.qcow2,if=virtio" \
|
-drive "file=/disk/vm-3.qcow2,if=virtio" \
|
||||||
-netdev "tap,id=net0,ifname=tap0,script=no,downscript=no" \
|
-netdev "tap,id=net0,ifname=tap0,script=no,downscript=no" \
|
||||||
-device "virtio-net-pci,netdev=net0,mac=00:22:33:00:00:01" \
|
-device "virtio-net-pci,netdev=net0,mac=00:22:33:00:00:01" \
|
||||||
-daemonize
|
-daemonize
|
||||||
```
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue