odhcpd.defaults 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. uci -q get dhcp.odhcpd && exit 0
  3. touch /etc/config/dhcp
  4. . /usr/share/libubox/jshn.sh
  5. json_load "$(cat /etc/board.json)"
  6. json_select network
  7. json_select lan
  8. json_get_vars protocol
  9. json_select ..
  10. json_select ..
  11. ODHCPDONLY=0
  12. V4MODE=disabled
  13. V6MODE=disabled
  14. [ -e /usr/sbin/dnsmasq ] || ODHCPDONLY=1
  15. case "$protocol" in
  16. # only enable server mode on statically addressed lan ports
  17. "static")
  18. V4MODE=server
  19. [ -e /proc/sys/net/ipv6 ] && V6MODE=server
  20. ;;
  21. esac
  22. uci get dhcp.lan 1>/dev/null 2>/dev/null || {
  23. uci batch <<EOF
  24. set dhcp.lan=dhcp
  25. set dhcp.lan.interface='lan'
  26. set dhcp.lan.start='100'
  27. set dhcp.lan.limit='150'
  28. set dhcp.lan.leasetime='12h'
  29. set dhcp.lan.domain='lan'
  30. EOF
  31. }
  32. uci batch <<EOF
  33. set dhcp.odhcpd=odhcpd
  34. set dhcp.odhcpd.maindhcp=$ODHCPDONLY
  35. set dhcp.odhcpd.leasefile=/tmp/hosts/odhcpd
  36. set dhcp.odhcpd.leasetrigger=/usr/sbin/odhcpd-update
  37. set dhcp.odhcpd.loglevel=4
  38. set dhcp.lan.dhcpv4=$V4MODE
  39. set dhcp.lan.dhcpv6=$V6MODE
  40. set dhcp.lan.ra=$V6MODE
  41. set dhcp.lan.ra_slaac=1
  42. add_list dhcp.lan.ra_flags=managed-config
  43. add_list dhcp.lan.ra_flags=other-config
  44. commit dhcp
  45. EOF