Mixing VM with gluon hardware

The freifunk gluon firmware is a relative common framework to create OpenWrt based firmware images for mesh networks with central VPN servers. The emulation environments using Linux bridge as virtual network can be directly connected to a device running a gluon firmware.

gluon adjustments

The current gluon version allows to change the LAN (or WAN) ports to mesh ports. This can either be enabled in the setup mode webinterface or using the commandline interface.

The packets will be encapsulated in a VXLAN packet. The VXLAN uses an id which has to be calculated on the node via:

lua -e 'print(tonumber(require("gluon.util").domain_seed_bytes("gluon-mesh-vxlan", 3), 16))'

Connect to gluon VXLAN

The configured gluon hardware has to be connected via ethernet to the our emulation host. Let us assume that the host is using interface enp8s0 for this connection and that the qemu instances are all connected to bridge br-qemu.

We must then create a vxlan interface on top of our normal ethernet interface, make sure that the ethernet interface is using an EUI64 based IPv6 link local address and insert the new interface in our bridge

cat > << "EOF" 
#! /bin/sh

# calculated on gluon node

xor2() {
        echo -n "${1:0:1}" 
        echo -n "${1:1:1}" | tr '0123456789abcdef' '23016745ab89efcd'

interface_linklocal() {
        local macaddr="$(cat /sys/class/net/"${ETH}"/address)" 
        local oldIFS="$IFS"; IFS=':'; set -- $macaddr; IFS="$oldIFS" 

        echo "fe80::$(xor2 "$1")$2:$3ff:fe$4:$5$6" 

ip addr add "$(interface_linklocal)"/64 dev "$ETH" 
ip link del "${VXLAN}" 
ip -6 link add "${VXLAN}" type vxlan \
   id "${VXLAN_ID}" \
   dstport 4789 \
   local "$(interface_linklocal)" \
   group ff02::15c \
   dev "${ETH}" \
   udp6zerocsumtx udp6zerocsumrx \
   ttl 1

ip link set "${VXLAN}" up master "${BRIDGE}" 

chmod +x

sudo ./