scripts/setup_lxd_network.sh

26 lines
767 B
Bash
Raw Permalink Normal View History

2024-09-22 09:22:28 +02:00
#!/bin/sh
set -x
if [[ $1 = "up" ]]
then
ip link add name virbr0 type bridge
ip link set up dev virbr0
ip addr add 10.0.0.1/8 dev virbr0
ip route append default via 10.0.0.1 dev virbr0
nft add table inet nat
nft add chain inet nat postrouting '{ type nat hook postrouting priority 100 ; }'
nft add rule inet nat postrouting oifname wlan0 masquerade
nft add rule inet filter forward ct state related,established accept
nft add rule inet filter forward iifname virbr0 oifname wlan0 accept
elif [[ $1 = "down" ]]
then
nft delete rule inet filter forward iifname virbr0 oifname wlan0 accept
nft delete rule inet filter forward ct state related,established accept
nft delete table inet nat
ip link del virbr0
else
echo "Use the 'up' or 'down' command"
fi