diff options
author | Simon Rettberg | 2018-07-18 17:11:24 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-18 17:11:24 +0200 |
commit | 63641877ec76864e0e3561b31a545edcbd9be0e3 (patch) | |
tree | 5c2dacc914bf774e3ac23ebd9ff4b5b7e0dc390c | |
parent | [pvs2] Fix iptables rules even more (diff) | |
download | mltk-63641877ec76864e0e3561b31a545edcbd9be0e3.tar.gz mltk-63641877ec76864e0e3561b31a545edcbd9be0e3.tar.xz mltk-63641877ec76864e0e3561b31a545edcbd9be0e3.zip |
[rfs-*] Use SMBIOS UUID as UID for DHCP requests
This is what the PXE rom does, so by using the same uid
we make sure that we keep the same address in case the
client is running in a dynamic address pool.
-rwxr-xr-x | core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ | 12 | ||||
-rw-r--r-- | core/rootfs/rootfs-stage31/data/inc/setup_network | 9 |
2 files changed, 18 insertions, 3 deletions
diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ index 2f8b878d..4548d1d1 100755 --- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ +++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/systemd-udhcpc++ @@ -4,7 +4,15 @@ NET_IF="$1" NET_IP="$(ip addr show dev "${NET_IF}" | grep -m1 '^\s*inet ' | awk -F " " '{print $2}' | awk -F "/" '{print $1}')" UDHCPC_OPTS="" -[ ! -z "$NET_IP" ] && UDHCPC_OPTS=" -r $NET_IP" +if [ -n "$NET_IP" ]; then + UDHCPC_OPTS="$UDHCPC_OPTS -r $NET_IP" +fi + +UID=$(dmidecode -s system-uuid | sed -r 's/^(..)(..)(..)(..)-(..)(..)-(..)(..)-(....)-/00\4\3\2\1\6\5\8\7\9/') +if [ "${#UID}" = 34 ]; then + echo "Using SMBIOS UID for DHCP" + UDHCPC_OPTS="$UDHCPC_OPTS -x 0x3d:$UID" +fi mkdir -p /run/udhcpc || echo "Could not create '/run/udhcpc'." @@ -12,7 +20,7 @@ mkdir -p /run/udhcpc || echo "Could not create '/run/udhcpc'." RET=$? if [ "$RET" != 0 ]; then - slxlog "udhcpc" "Could not run 'udhcpc${UDHCPC_OPTS}' on ${NET_IF}." + slxlog "udhcpc" "Could not run 'udhcpc ${UDHCPC_OPTS}' on ${NET_IF}." fi exit "$RET" diff --git a/core/rootfs/rootfs-stage31/data/inc/setup_network b/core/rootfs/rootfs-stage31/data/inc/setup_network index b067100d..c3ab7473 100644 --- a/core/rootfs/rootfs-stage31/data/inc/setup_network +++ b/core/rootfs/rootfs-stage31/data/inc/setup_network @@ -102,12 +102,19 @@ if [ -n "$GATEWAY" ]; then echo -n "$GATEWAY" > "/run/firstgw" fi +UID=$(dmidecode -s system-uuid | sed -r 's/^(..)(..)(..)(..)-(..)(..)-(..)(..)-(....)-/00\4\3\2\1\6\5\8\7\9/') +if [ "${#UID}" = 34 ]; then + echo "Using SMBIOS UID for DHCP" + PARAM="$PARAM -x 0x3d:$UID" +fi + # save our variables for retry on fail ff. echo "CLIENTIP=$CLIENTIP" >> /run/network.conf echo "GATEWAY=$GATEWAY" >> /run/network.conf echo "BRIDGE=$BRIDGE" >> /run/network.conf +echo "UID=$UID" >> /run/network.conf -udhcpc $PARAM -O ntpsrv -O domain -O wpad -O search -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" +udhcpc $PARAM -x "0x3d:$UID" -O ntpsrv -O domain -O wpad -O search -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" URET=$? # udhcpc return value will be return value of this script [ -z "$CLIENTIP" ] && CLIENTIP=$(cat /run/firstip) |