This repository has been archived on 2024-05-11. You can view files and clone it, but cannot push or open issues or pull requests.
gluon-supernode-docker/batman/entry-point.sh

38 lines
1.3 KiB
Bash

#!/bin/sh
set -e
batctl meshif ${BATMAN_INTERFACE} interface create
ip link add ${BATMAN_BRIDGE} type bridge
ip link set ${BATMAN_INTERFACE} master ${BATMAN_BRIDGE}
ip link set ${BATMAN_INTERFACE} up
ip link set ${BATMAN_BRIDGE} up
# setup ips
if [ "${BATMAN_BRIDGE_IPV4}" ] ; then
ip -4 addr add ${BATMAN_BRIDGE_IPV4} dev ${BATMAN_BRIDGE}
fi
if [ "${BATMAN_BRIDGE_IPV6}" ] ; then
ip -6 addr add ${BATMAN_BRIDGE_IPV6} dev ${BATMAN_BRIDGE}
fi
# mark node as dhcp server
batctl meshif ${BATMAN_INTERFACE} gw server ${BATMAN_LIMIT_DOWNLOAD}Mbit/${BATMAN_LIMIT_UPLOAD}Mbit
# configure routing
ip rule add iif ${BATMAN_BRIDGE} table ${BATMAN_FORWARD_TABLE}
[ "${BATMAN_FORWARD_GATEWAY4}" ] && \
ip -4 route add table ${BATMAN_FORWARD_TABLE} default via ${BATMAN_FORWARD_GATEWAY4}
[ "${BATMAN_FORWARD_GATEWAY6}" ] && \
ip -6 route add table ${BATMAN_FORWARD_TABLE} default via ${BATMAN_FORWARD_GATEWAY6}
nft add table ip nat || true
nft add chain 'ip nat POSTROUTING { type nat hook postrouting priority srcnat; policy accept; }' || true
nft add rule nat POSTROUTING counter masquerade || true
nft add table ip6 nat || true
nft add chain 'ip6 nat POSTROUTING { type nat hook postrouting priority srcnat; policy accept; }' || true
nft add rule ip6 nat counter masquerade || true
while true ; do
sleep 1
done