aboutsummaryrefslogtreecommitdiff
path: root/package/network/services/odhcpd/files/odhcpd.defaults
blob: 1350636ba4300f4ef69508576597de99c0193c1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
uci -q get dhcp.odhcpd && exit 0
touch /etc/config/dhcp

. /usr/share/libubox/jshn.sh

json_load "$(cat /etc/board.json)"
json_select network
json_select lan
json_get_vars protocol
json_select ..
json_select ..

ODHCPDONLY=0
V4MODE=disabled
V6MODE=disabled

[ -e /usr/sbin/dnsmasq ] || ODHCPDONLY=1

case "$protocol" in
# only enable server mode on statically addressed lan ports
"static")
	V4MODE=server
	[ -e /proc/sys/net/ipv6 ] && V6MODE=server
	;;
esac

uci get dhcp.lan 1>/dev/null 2>/dev/null || {
uci batch <<EOF
set dhcp.lan=dhcp
set dhcp.lan.interface='lan'
set dhcp.lan.start='100'
set dhcp.lan.limit='150'
set dhcp.lan.leasetime='12h'
set dhcp.lan.domain='lan'
EOF
}

uci batch <<EOF
set dhcp.odhcpd=odhcpd
set dhcp.odhcpd.maindhcp=$ODHCPDONLY
set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
set dhcp.odhcpd.loglevel=4
set dhcp.lan.dhcpv4=$V4MODE
set dhcp.lan.dhcpv6=$V6MODE
set dhcp.lan.ra=$V6MODE
set dhcp.lan.ra_slaac=1
add_list dhcp.lan.ra_flags=managed-config
add_list dhcp.lan.ra_flags=other-config
commit dhcp
EOF