[Dnsmasq-discuss] Create temporary leases for DHCPOFFER actions, setup.sh
Geert Stappers
stappers at stappers.nl
Wed Jul 13 14:52:04 UTC 2022
On Fri, Jul 08, 2022 at 10:26:35PM +0200, Petr Menšík wrote:
>
> I am attaching also setup.sh, which I used to emulate starting multiple
> clients at similar time. I configured dnsmasq listening on virbr1 device and
> offering addresses. Then run that script as root and record communication in
> wireshark. Unlike current situation, there should not be any NACKs present.
> Even though ISC dhclient handles NACK well and is able to retry, unlike some
> netbooting firmware, which fails the boot in such situation.
>
> Comments or testing would be welcome.
Idea: putting the `setup.sh` into the contrib directory
Regards
Geert Stappers
What follows is the script
--------------------------
#!/bin/sh
: ${BRIDGE:=virbr1}
NS=dhcp-test
INSTANCES=${1:-16}
WAIT=${2:-80}
ip netns add $NS
ip -netns $NS link set lo up
# Make sure old addresses are forgotten
rm -f /var/lib/dhclient/dhclient-testc*.{lease,log}
for I in $(seq 1 $INSTANCES); do
ip link add testc$I type veth peer name testh$I
ip link set testh$I master $BRIDGE up
ip link set testc$I netns $NS up
done
for I in $(seq 1 $INSTANCES); do
COMMON=dhclient-testc$I
LIB=/var/lib/dhclient/$COMMON
RUN=/run/$COMMON
ip netns exec $NS dhclient -v -d -1 -nc \
-H test-$I \
-sf /bin/true \
-pf $RUN.pid \
-lf $LIB.lease \
-e PEERDNS=no \
testc$I >& $LIB.log &
done
ip -netns $NS link
#while ps $(cat /run/dhclient-testc*.pid); do sleep 1; done
sleep $WAIT
cat /var/lib/dhclient/dhclient-testc*.log
grep 'DHCPOFFER' /var/lib/dhclient/dhclient-testc*.log
kill $(cat /run/dhclient-testc*.pid)
ip netns del $NS 2>/dev/null
--------------------------
More information about the Dnsmasq-discuss
mailing list