ifupdown-ng / ifupdown-ng

flexible ifup/ifdown implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DHCP clients' config files

ivan98 opened this issue · comments

I'm running ifupdown-ng 0.11.3 and dhcpcd 9.4.1 on Alpine Linux 3.15.4

The dhcp executor script supports the following 4 options of dhcpcd, but there is a duplicate of the -i option. See lines 18 & 19.

start() {
case "$1" in
dhcpcd)
[ -n "$IF_DHCP_HOSTNAME" ] && optargs="$optargs -h $IF_DHCP_HOSTNAME"
[ -n "$IF_DHCP_VENDOR" ] && optargs="$optargs -i $IF_DHCP_VENDOR"
[ -n "$IF_DHCP_CLIENT_ID" ] && optargs="$optargs -i $IF_DHCP_CLIENT_ID"
[ -n "$IF_DHCP_LEASETIME" ] && optargs="$optargs -l $IF_DHCP_LEASETIME"
${MOCK} /sbin/dhcpcd $optargs $IFACE
;;

Accordingly, as shown below, it is a typo from -I to -i (lowercase)

# dhcpcd --help
usage: dhcpcd	[-146ABbDdEGgHJKLMNPpqTV]
		[-C, --nohook hook] [-c, --script script]
		[-e, --env value] [-F, --fqdn FQDN] [-f, --config file]
		[-h, --hostname hostname] [-I, --clientid clientid]
		[-i, --vendorclassid vendorclassid] [-j, --logfile logfile]
		[-l, --leasetime seconds] [-m, --metric metric]
		[-O, --nooption option] [-o, --option option]
		[-Q, --require option] [-r, --request address]
		[-S, --static value]
		[-s, --inform address[/cidr[/broadcast_address]]]
 [--inform6]		[-t, --timeout seconds] [-u, --userclass class]
		[-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w]
		[--waitip [4 | 6]] [-y, --reboot seconds]
		[-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern]
		[-z, --allowinterfaces pattern] [--inactive] [interface] [...]
       dhcpcd	-n, --rebind [interface]
       dhcpcd	-k, --release [interface]
       dhcpcd	-U, --dumplease interface
       dhcpcd	--version
       dhcpcd	-x, --exit [interface]

dhcpcd has many options, but only 4 are mapped in ifupdown-ng. Actually, instead of trying to individually map options of dhcpcd one by one, why not instead allow config file to be specified, like what was done for dhclient in lines 25 to 27 below?

dhclient)
# Specific config file given?
if [ -n "$IF_DHCP_CONFIG" ]; then
optargs="$optargs -cf $IF_DHCP_CONFIG"
fi

If ifupdown-ng allows config files of the various dhcp clients to be specified, then there is no need to individually map the many options of the different dhcp clients.

Please consider this approach?

@ivan98: @profplump has done a PR: