#!/bin/sh

WAN_IFACE="$(uci get network.wan.device | cut -d' ' -f2)"

WAN_IP="$(ip addr show | grep "$WAN_IFACE" | awk '{print $2}' | cut -d/ -f1 | tail -n 1)"

WAN_GATEWAY="$(ip route show default | awk '/default/ {print $3}')"

WAN_IPRANGE="$(echo "$WAN_GATEWAY" | sed "s/([0-9]*.[0-9]*.[0-9]*).[0-9]*/1.0/")"

MACVLAN_IP="$(echo "$WAN_GATEWAY" | sed "s/([0-9]*.[0-9]*.[0-9]*).[0-9]*/1.234/")"


ip link set "$WAN_IFACE" promisc on


docker network create -d macvlan --subnet="$WAN_IPRANGE"/24 --gateway="$WAN_GATEWAY" -o parent="$WAN_IFACE" macnet
