#!/bin/bash -eu DIR="$(dirname "${BASH_SOURCE[0]}")" fix_nft_drops() { local j s='"add chain \(.family) \(.table) \(.name) { policy \(.policy); }"' if [ -f "$DIR/restore-nft.conf" ]; then nft -f "$DIR/restore-nft.conf" fi j="$(nft -j list chains | jq '.[][].chain | select(.policy == "drop")')" jq -r ".policy=\"accept\" | $s" <<< "$j" jq -r "$s" <<< "$j" > "$DIR/restore-nft.conf" } command -V dnsmasq > /dev/null command -V nft > /dev/null if [ "$EUID" != 0 ]; then echo 'this script must be run as root' >&2 exit 1 fi BRIDGE="${1-virbr0}" modprobe nft_masq sysctl net.ipv4.conf.all.forwarding=1 if ! ip link show "$BRIDGE" 2> /dev/null; then ip link add "$BRIDGE" type bridge fi ip link set dev "$BRIDGE" up ip address flush dev "$BRIDGE" ip address add 192.168.123.1/24 dev "$BRIDGE" nft -f- <