Remove dhclient

This commit is contained in:
Kroese 2023-05-03 16:53:22 +02:00 committed by GitHub
parent 276921f42d
commit 5e328c1562

View file

@ -20,7 +20,7 @@ set -eu
configureDHCP() { configureDHCP() {
VM_NET_VLAN="vlan" VM_NET_VLAN="${VM_NET_TAP}_vlan"
GATEWAY=$(ip r | grep default | awk '{print $3}') GATEWAY=$(ip r | grep default | awk '{print $3}')
NETWORK=$(ip -o route | grep "${VM_NET_DEV}" | grep -v default | awk '{print $1}') NETWORK=$(ip -o route | grep "${VM_NET_DEV}" | grep -v default | awk '{print $1}')
IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/) IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
@ -54,18 +54,6 @@ configureDHCP() {
ip address flush "${VM_NET_DEV}" ip address flush "${VM_NET_DEV}"
ip address flush "${VM_NET_TAP}" ip address flush "${VM_NET_TAP}"
echo "INFO: Acquiring an IP address via DHCP using MAC address ${VM_NET_MAC}..."
DHCP_IP=$(dhclient -v "${VM_NET_TAP}" 2>&1 | grep ^bound | cut -d' ' -f3)
if [[ "${DHCP_IP}" == [0-9.]* ]]; then
echo "INFO: Successfully acquired IP ${DHCP_IP} from the DHCP server..."
else
echo "ERROR: Cannot acquire an IP address from the DHCP server" && exit 17
fi
ip address flush "${VM_NET_TAP}"
{ set +x; } 2>/dev/null { set +x; } 2>/dev/null
TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex) TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex)
@ -242,5 +230,6 @@ else
fi fi
[ "$DEBUG" = "Y" ] && echo && echo "Finished network setup.." && echo
NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0" NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0"
[ "$DEBUG" = "Y" ] && echo && echo "Finished network setup.." && echo