Commit 7ad3c6bf authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: DNS resolution

parent 398d6457
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -92,12 +92,12 @@ configureDNS () {

  for nameserver in "${nameservers[@]}"; do
    nameserver=$(echo "$nameserver" | sed 's/#.*//' )
    if ! [[ "$nameserver" =~ .*:.* ]]; then
    [[ "$nameserver" =~ .*:.* ]] && continue
    [[ "$nameserver" == "127.0"* ]] && nameserver=$GATEWAY
    [[ -z "$DNS_SERVERS" ]] && DNS_SERVERS="$nameserver" || DNS_SERVERS="$DNS_SERVERS,$nameserver"
    fi
  done

  [[ -z "$DNS_SERVERS" ]] && DNS_SERVERS="1.1.1.1"
  [[ -z "$DNS_SERVERS" ]] && DNS_SERVERS=$GATEWAY

  DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:dns-server,$DNS_SERVERS --dhcp-option=option:router,${VM_NET_IP%.*}.1"

@@ -158,8 +158,6 @@ configureNAT () {
  done

  # Add internet connection to the VM
  IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)

  iptables -t nat -A POSTROUTING -o "${VM_NET_DEV}" -j MASQUERADE
  # shellcheck disable=SC2086
  iptables -t nat -A PREROUTING -i "${VM_NET_DEV}" -d "${IP}" -p tcp $CONTROL_PORT_ARGS -j DNAT --to $VM_NET_IP
@@ -233,12 +231,10 @@ update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy > /dev/null

VM_NET_MAC="${VM_NET_MAC//-/:}"
GATEWAY=$(ip r | grep default | awk '{print $3}')
IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)

if [[ "${DEBUG}" == [Yy1]* ]]; then

  IP=$(ip address show dev "${VM_NET_DEV}" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/)
  info "Container IP is ${IP} with gateway ${GATEWAY}" && echo

fi

if [[ "${DHCP}" == [Yy1]* ]]; then