Commit be0daa48 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

DHCP fixes

DHCP fixes
parents 2be071fe 5e328c15
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@ RUN apt-get update && apt-get -y upgrade && \
	dnsmasq \
	net-tools \
	ca-certificates \
	isc-dhcp-client \
	netcat-openbsd \
	qemu-system-x86 \
    && apt-get clean
+3 −14
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ set -eu

configureDHCP() {

  VM_NET_VLAN="vlan"
  VM_NET_VLAN="${VM_NET_TAP}_vlan"
  GATEWAY=$(ip r | grep default | awk '{print $3}')
  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/)
@@ -54,18 +54,6 @@ configureDHCP() {
  ip address flush "${VM_NET_DEV}"
  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

  TAP_NR=$(</sys/class/net/"${VM_NET_TAP}"/ifindex)
@@ -242,5 +230,6 @@ else

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"

[ "$DEBUG" = "Y" ] && echo && echo "Finished network setup.." && echo