Skip to content

Instantly share code, notes, and snippets.

@vickiegpt
Created October 13, 2025 01:10
Show Gist options
  • Select an option

  • Save vickiegpt/a7ddc488c03615aa62725b92bfb54614 to your computer and use it in GitHub Desktop.

Select an option

Save vickiegpt/a7ddc488c03615aa62725b92bfb54614 to your computer and use it in GitHub Desktop.
Setup Mesh Device
#!/bin/bash
set -e
# VXLAN network info
VNI=100
DEV=enp23s0f0np0
BR=br0
# detect this host's underlay IP
SELF_IP=$(ip -4 addr show $DEV | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
echo "Setting up bridge on $SELF_IP"
# list all other hosts’ underlay IPs
PEERS=("10.10.1.1" "10.10.1.2" "10.10.1.3" "10.10.1.4")
# clean up if rerun
ip link del $BR 2>/dev/null || true
ip link del vxlan${VNI} 2>/dev/null || true
# create bridge
ip link add $BR type bridge
ip link set $BR up
# create VXLAN interface (full-mesh mode)
for peer in "${PEERS[@]}"; do
if [ "$peer" != "$SELF_IP" ]; then
ip link add vxlan${VNI}-${peer//./_} type vxlan id $VNI \
local $SELF_IP remote $peer dstport 4789 dev $DEV
ip link set vxlan${VNI}-${peer//./_} up
ip link set vxlan${VNI}-${peer//./_} master $BR
fi
done
# assign overlay IP (based on host underlay)
case $SELF_IP in
10.10.1.1) ip addr add 192.168.100.1/24 dev $BR ;;
10.10.1.2) ip addr add 192.168.100.2/24 dev $BR ;;
10.10.1.3) ip addr add 192.168.100.3/24 dev $BR ;;
10.10.1.4) ip addr add 192.168.100.4/24 dev $BR ;;
esac
# optional: add TAPs for local QEMU
for i in $(seq 0 1); do
ip tuntap add tap$i mode tap
ip link set tap$i up
ip link set tap$i master $BR
done
echo "Bridge $BR with VXLAN mesh established."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment