b14cf98 router: log “Sending a RA on lan” at LOG_DEBUG
c2810fe odhcpd: update cmake file
8c2c065 odhcpd: convert README to markdown
3b96480 odhcpd: allow the use of an alternative cfg file
7328bfe odhcpd: remove confusing #defines
cdb9e5b odhcpd: improve RFC9096 § 3.5 SLAAC compliance
RFC9096 § 3.5 SLAAC compliance introduces a new config option (odhcpd
piofolder), which may wear out the flash under certain conditions (for
example: ISPs with dynamic IPv6 prefixes which disconnect the clients
every X hours).
Therefore, setting "dhcp.odhcpd.piofolder" to persistent storage in the
router flash is not advisable and should be set to other kinds of
persistent storage such as USBs, SDs, NVMEs...
In order to prevent wearing out the router flash it's set to ephemeral
storage by default (tmp):
uci set dhcp.odhcpd.piofolder="/tmp/odhcpd-piofolder"
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
(cherry picked from commit ea79b5875a)
63 lines
1.3 KiB
Bash
63 lines
1.3 KiB
Bash
#!/bin/sh
|
|
|
|
if [ -n "$(uci -q get dhcp.odhcpd)" ]; then
|
|
if [ -z "$(uci -q get dhcp.odhcpd.piofolder)" ]; then
|
|
uci set dhcp.odhcpd.piofolder=/tmp/odhcpd-piofolder
|
|
uci commit dhcp
|
|
fi
|
|
|
|
exit 0
|
|
fi
|
|
|
|
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.odhcpd.piofolder=/tmp/odhcpd-piofolder
|
|
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
|