#!/bin/sh

# Remove default instances
# while uci -q delete dhcp.@dnsmasq[0]; do :; done
# while uci -q delete dhcp.@dhcp[0]; do :; done

uci set network.wan.mode=2
# For single PDN
uci set network.lan.disabled=0

# For multi-PDN
for INST in lan1 lan2 lan3
do
	uci set network.${INST}=interface
	uci set network.${INST}.type='bridge'
	uci set network.${INST}.proto='static'
	uci set network.${INST}.ipaddr="192.168.${INST: -1}.1"
	uci set network.${INST}.netmask='255.255.255.0'
	uci set network.${INST}.disabled='1'
	uci set network.${INST}.ip6assign='60'

	uci set dhcp.${INST}_dns="dnsmasq"
	uci set dhcp.${INST}_dns.port="0"
	uci set dhcp.${INST}_dns.leasefile="/tmp/dhcp.leases.${INST}"

	uci set dhcp.${INST}=dhcp
	uci set dhcp.${INST}.start='100'
	uci set dhcp.${INST}.leasetime='1m'
	uci set dhcp.${INST}.limit='150'
	uci set dhcp.${INST}.instance="${INST}_dns"
	uci set dhcp.${INST}.interface="${INST}"
	uci set dhcp.${INST}.ra='server'
	uci set dhcp.${INST}.dhcpv6='server'
	uci set dhcp.${INST}.ra_management='1'
done
uci commit network
uci commit dhcp

# /etc/config/firewall
uci del firewall.cfg02dc81.network
uci set firewall.cfg02dc81.network='lan lan1 lan2 lan3'
uci commit firewall
