39 lines
1.0 KiB
Django/Jinja
39 lines
1.0 KiB
Django/Jinja
#!/bin/bash
|
|
set -e
|
|
|
|
LAB_NAME="{{ gateway_config.lab_name }}"
|
|
VNI="{{ gateway_config.vni }}"
|
|
BR_IF="br-${LAB_NAME}"
|
|
VXLAN_IF="vxlan${VNI}"
|
|
LAB_IF="{{ gateway_config.lab_if }}"
|
|
|
|
# Wait for VXLAN interface
|
|
timeout=30
|
|
while [ $timeout -gt 0 ]; do
|
|
if ip link show ${VXLAN_IF} >/dev/null 2>&1; then
|
|
break
|
|
fi
|
|
sleep 1
|
|
timeout=$((timeout-1))
|
|
done
|
|
|
|
# Create bridge
|
|
if ! ip link show ${BR_IF} &>/dev/null; then
|
|
ip link add ${BR_IF} type bridge
|
|
ip link set ${BR_IF} type bridge stp_state {{ bridge_stp | ternary('1', '0') }}
|
|
ip link set ${BR_IF} type bridge forward_delay {{ bridge_forward_delay }}
|
|
fi
|
|
|
|
# Add interfaces to bridge
|
|
ip link set ${VXLAN_IF} master ${BR_IF}
|
|
ip link set ${LAB_IF} master ${BR_IF}
|
|
|
|
# Configure bridge IP (for DHCP server)
|
|
ip addr flush dev ${BR_IF}
|
|
ip addr add {{ gateway_config.subnet | ipaddr('1') | ipaddr('address') }}/{{ gateway_config.subnet | ipaddr('prefix') }} dev ${BR_IF}
|
|
|
|
# Bring everything up
|
|
ip link set ${LAB_IF} up
|
|
ip link set ${VXLAN_IF} up
|
|
ip link set ${BR_IF} up
|