Unverified Commit 724c5230 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Add IPv6 support (#699)

parent 1f4d5850
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ COPY --chmod=744 ./web/conf/nginx.conf /etc/nginx/sites-enabled/web.conf
VOLUME /storage
EXPOSE 22 80 5900

ENV CPU_CORES="1"
ENV RAM_SIZE="1G"
ENV CPU_CORES="2"
ENV RAM_SIZE="2G"
ENV DISK_SIZE="16G"
ENV BOOT="http://example.com/image.iso"

+2 −2
Original line number Diff line number Diff line
@@ -176,13 +176,13 @@ kubectl apply -f https://raw.githubusercontent.com/qemus/qemu/refs/heads/master/

### How do I change the amount of CPU or RAM?

  By default, the container will be allowed to use a maximum of 1 CPU core and 1 GB of RAM.
  By default, the container will be allowed to use a maximum of 2 CPU cores and 2 GB of RAM.

  If you want to adjust this, you can specify the desired amount using the following environment variables:

  ```yaml
  environment:
    RAM_SIZE: "4G"
    RAM_SIZE: "8G"
    CPU_CORES: "4"
  ```

+3 −0
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ getURL() {
    "kubuntu" )
      name="Kubuntu"
      url="https://cdimage.ubuntu.com/kubuntu/releases/24.10/release/kubuntu-24.10-desktop-amd64.iso" ;;
    "lmde" )
      name="Linux Mint Debian Edition"
      url="https://mirror.rackspace.com/linuxmint/iso/debian/lmde-6-cinnamon-64bit.iso" ;;
    "macos" | "osx" )
      name="macOS"
      error "To install $name use: https://github.com/dockur/macos" && return 1 ;;
+1 −5
Original line number Diff line number Diff line
@@ -616,14 +616,10 @@ DISK4_FILE="/storage4/${DISK_NAME}4"
if [ -z "$DISK_FMT" ]; then
  if [ -f "$DISK1_FILE.qcow2" ]; then
    DISK_FMT="qcow2"
  else
    if [[ "$BOOT" ==  *".qcow2" ]] && [ ! -f "$DISK1_FILE.img" ]; then
      DISK_FMT="qcow2"
  else
    DISK_FMT="raw"
  fi
fi
fi

if [ -z "$ALLOCATE" ]; then
  ALLOCATE="N"
+14 −28
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ set -Eeuo pipefail
: "${VM_NET_MAC:="$MAC"}"
: "${VM_NET_HOST:="QEMU"}"
: "${VM_NET_IP:="20.20.20.21"}"
: "${VM_NET_IP6:="fdb4:ccc4:abd8::12"}"

: "${DNSMASQ_OPTS:=""}"
: "${DNSMASQ:="/usr/sbin/dnsmasq"}"
@@ -120,6 +119,12 @@ configureDNS() {

  DNSMASQ_OPTS=$(echo "$DNSMASQ_OPTS" | sed 's/\t/ /g' | tr -s ' ' | sed 's/^ *//')

  if [[ "$DEBUG" == [Yy1]* ]]; then
   DNSMASQ_OPTS+=" -d"
   $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS} &
   return 0
  fi

  if ! $DNSMASQ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}; then
    error "Failed to start dnsmasq, reason: $?" && return 1
  fi
@@ -215,13 +220,7 @@ configureNAT() {
  fi

  if ! ip address add "${VM_NET_IP%.*}.1/24" broadcast "${VM_NET_IP%.*}.255" dev dockerbridge; then
    error "Failed to add IP address!" && return 1
  fi

  if [ -n "$IP6" ]; then
    if ! ip -6 address add dev dockerbridge scope global "$VM_NET_IP6"; then
      error "Failed to add IPv6 address"
    fi
    error "Failed to add IP address pool!" && return 1
  fi

  while ! ip link set dockerbridge up; do
@@ -279,19 +278,6 @@ configureNAT() {
    iptables -A POSTROUTING -t mangle -p udp --dport bootpc -j CHECKSUM --checksum-fill > /dev/null 2>&1 || true
  fi

  if [ -n "$IP6" ] && ip6tables -t nat -A POSTROUTING -o "$VM_NET_DEV" -j MASQUERADE; then

    # shellcheck disable=SC2086
    if ! ip6tables -t nat -A PREROUTING -i "$VM_NET_DEV" -d "$IP6" -p tcp${exclude} -j DNAT --to "$VM_NET_IP6"; then
      error "Failed to configure IPv6 tables!"
    fi

    if ! ip6tables -t nat -A PREROUTING -i "$VM_NET_DEV" -d "$IP6" -p udp  -j DNAT --to "$VM_NET_IP6"; then
      error "Failed to configure IPv6 tables!"
    fi

  fi

  NET_OPTS="-netdev tap,id=hostnet0,ifname=$VM_NET_TAP"

  if [ -c /dev/vhost-net ]; then
@@ -431,8 +417,8 @@ getInfo() {
  GATEWAY=$(ip route list dev "$VM_NET_DEV" | awk ' /^default/ {print $3}' | head -n 1)
  IP=$(ip address show dev "$VM_NET_DEV" | grep inet | awk '/inet / { print $2 }' | cut -f1 -d/ | head -n 1)

  IP6=$(ifconfig -a | grep inet6)
  if [ -f /proc/net/if_inet6 ] && [ -n "$IP6" ]; then
  IP6=""
  if [ -f /proc/net/if_inet6 ] && [ -n "$(ifconfig -a | grep inet6)" ]; then
    IP6=$(ip -6 addr show dev "$VM_NET_DEV" scope global up)
    [ -n "$IP6" ] && IP6=$(echo "$IP6" | sed -e's/^.*inet6 \([^ ]*\)\/.*$/\1/;t;d' | head -n 1)
  fi
@@ -490,7 +476,7 @@ else

      closeBridge
      NETWORK="user"
      warn "falling back to usermode networking! Performance will be bad and port mapping will not work."
      warn "falling back to user-mode networking! Performance will be bad and port mapping will not work."

    fi

@@ -498,7 +484,7 @@ else

  if [[ "${NETWORK,,}" == "user"* ]]; then

    # Configure for usermode networking (slirp)
    # Configure for user-mode networking (slirp)
    configureUser || exit 24

  fi
Loading