isc-dhcp: dhcrelay: Add more UCI options
Add more options to dhcrelay UCI and init script: - enabled - interfaces: Listen interfaces - relay_mode: What to do about packets that already have a relay option Also mark /etc/config/dhcrelay as conffile Signed-off-by: Bruno Randolf <br1@einfach.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@38446 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
8aba712580
commit
a8ce2d5f8c
@ -55,11 +55,19 @@ $(call Package/isc-dhcp-relay-ipv6/description)
|
||||
This package is compiled with IPv4 support only.
|
||||
endef
|
||||
|
||||
define Package/isc-dhcp-relay-ipv4/conffiles
|
||||
/etc/config/dhcrelay
|
||||
endef
|
||||
|
||||
define Package/isc-dhcp-relay-ipv6/description
|
||||
$(call Package/isc-dhcp-relay/description)
|
||||
This package is compiled with IPv4 and IPv6 support.
|
||||
endef
|
||||
|
||||
define Package/isc-dhcp-relay-ipv6/conffiles
|
||||
/etc/config/dhcrelay
|
||||
endef
|
||||
|
||||
define Package/isc-dhcp-client-ipv4
|
||||
$(call Package/isc-dhcp/Default)
|
||||
TITLE+= client (without IPv6)
|
||||
|
@ -8,13 +8,37 @@ SERVICE_PID_FILE="/var/run/dhcrelay4.pid"
|
||||
SERVICE_USE_PID=1
|
||||
|
||||
start() {
|
||||
local relay_dhcpserver
|
||||
|
||||
. /lib/functions/network.sh
|
||||
config_load dhcrelay
|
||||
config_get relay_dhcpserver ipv4 dhcpserver
|
||||
local args=""
|
||||
|
||||
local enabled
|
||||
config_get_bool enabled ipv4 enabled 0
|
||||
[ "$enabled" -eq 0 ] && return 0
|
||||
|
||||
# listen interfaces
|
||||
local interfaces
|
||||
local ifname
|
||||
config_get interfaces ipv4 interfaces
|
||||
for net in $interfaces; do
|
||||
if network_get_device ifname "$net"; then
|
||||
append args "-i $ifname"
|
||||
fi
|
||||
done
|
||||
|
||||
# relay mode
|
||||
local relay_mode
|
||||
config_get relay_mode ipv4 relay_mode
|
||||
[ -n "$relay_mode" ] && append args "-m $relay_mode"
|
||||
|
||||
# dhcp server address
|
||||
local server
|
||||
config_get server ipv4 dhcpserver
|
||||
[ -n "$server" ] || return 0
|
||||
append args "$server"
|
||||
|
||||
service_start /usr/sbin/dhcrelay -4 -q \
|
||||
-pf $SERVICE_PID_FILE $relay_dhcpserver
|
||||
-pf $SERVICE_PID_FILE $args
|
||||
}
|
||||
|
||||
stop() {
|
||||
|
@ -1,6 +1,20 @@
|
||||
|
||||
config dhcrelay ipv4
|
||||
option dhcpserver '192.0.2.10'
|
||||
option 'enabled' '0'
|
||||
|
||||
# IP address of the server
|
||||
option 'dhcpserver' '192.0.2.10'
|
||||
|
||||
# network interfaces to listen on (e.g. lan or wan)
|
||||
option 'interfaces' ''
|
||||
|
||||
# What to do about packets that already have a relay option:
|
||||
# 'append': Forward and append our own relay option
|
||||
# 'replace': Forward, but replace theirs with ours (default)
|
||||
# 'forward': Forward without changes
|
||||
# 'discard': Don't forward
|
||||
option 'relay_mode' ''
|
||||
|
||||
|
||||
config dhcrelay ipv6
|
||||
# option dhcpserver '2001:db8:1::1'
|
||||
|
Loading…
x
Reference in New Issue
Block a user