diff options
author | Daniel Golle <daniel@makrotopia.org> | 2021-02-14 22:39:24 +0000 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2021-02-15 00:34:43 +0000 |
commit | d79eeba6887b69d6ee608480d267bd1bef768cb7 (patch) | |
tree | 32449af0bec5c2e0362473c7c884083b93fe32e3 /package/network | |
parent | 304df2836a2c02a5f63df64d8b23100d6baaa3d3 (diff) | |
download | upstream-d79eeba6887b69d6ee608480d267bd1bef768cb7.tar.gz upstream-d79eeba6887b69d6ee608480d267bd1bef768cb7.tar.bz2 upstream-d79eeba6887b69d6ee608480d267bd1bef768cb7.zip |
odhcpd: setup dhcpv4 server automagically
Automatically setup dhcpv4 server just like it's done for dhcpv6.
To select whether odhcpd or dnsmasq are serving DHCPv4 requests there
still is the 'maindhcp' option. To make things less confusing, make
sure things really work out-of-the-box in case dnsmasq is not even
installed at the time the uci-defaults script is being run.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/network')
-rw-r--r-- | package/network/services/odhcpd/Makefile | 2 | ||||
-rw-r--r-- | package/network/services/odhcpd/files/odhcpd.defaults | 30 |
2 files changed, 26 insertions, 6 deletions
diff --git a/package/network/services/odhcpd/Makefile b/package/network/services/odhcpd/Makefile index fe3e526ef1..799a63c23d 100644 --- a/package/network/services/odhcpd/Makefile +++ b/package/network/services/odhcpd/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=odhcpd -PKG_RELEASE:=1 +PKG_RELEASE:=$(AUTORELEASE) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcpd.git diff --git a/package/network/services/odhcpd/files/odhcpd.defaults b/package/network/services/odhcpd/files/odhcpd.defaults index 5a1706f785..1350636ba4 100644 --- a/package/network/services/odhcpd/files/odhcpd.defaults +++ b/package/network/services/odhcpd/files/odhcpd.defaults @@ -11,20 +11,40 @@ 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") [ -e /proc/sys/net/ipv6 ] && MODE=server || MODE=disabled ;; -*) MODE=disabled ;; +"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=0 +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.dhcpv6=$MODE -set dhcp.lan.ra=$MODE +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 |