From be15557798500499130d72e160f4698474ab9fce Mon Sep 17 00:00:00 2001 From: Kroese Date: Thu, 20 Mar 2025 03:05:50 +0100 Subject: [PATCH] fix: User-mode networking (#942) --- src/config.sh | 2 +- src/network.sh | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/config.sh b/src/config.sh index b1877bd..0a57368 100644 --- a/src/config.sh +++ b/src/config.sh @@ -37,7 +37,7 @@ if [[ "$RAM_CHECK" != [Nn]* ]]; then fi if [[ "$DEBUG" == [Yy1]* ]]; then - printf "Arguments:\n\n%s" "${ARGS// -/$'\n-'}" && echo + printf "Arguments:\n\n%s\n\n" "${ARGS// -/$'\n-'}" fi return 0 diff --git a/src/network.sh b/src/network.sh index 564ee51..e8a904f 100644 --- a/src/network.sh +++ b/src/network.sh @@ -104,15 +104,21 @@ configureDHCP() { configureDNS() { - # dnsmasq configuration: - DNSMASQ_OPTS+=" --dhcp-range=$VM_NET_IP,$VM_NET_IP --dhcp-host=$VM_NET_MAC,,$VM_NET_IP,$VM_NET_HOST,infinite --dhcp-option=option:netmask,255.255.255.0" - # Create lease file for faster resolve echo "0 $VM_NET_MAC $VM_NET_IP $VM_NET_HOST 01:$VM_NET_MAC" > /var/lib/misc/dnsmasq.leases chmod 644 /var/lib/misc/dnsmasq.leases + # dnsmasq configuration: + DNSMASQ_OPTS+=" --dhcp-authoritative" + + # Set DHCP range and host + DNSMASQ_OPTS+=" --dhcp-range=$VM_NET_IP,$VM_NET_IP" + DNSMASQ_OPTS+=" --dhcp-host=$VM_NET_MAC,,$VM_NET_IP,$VM_NET_HOST,infinite" + # Set DNS server and gateway - DNSMASQ_OPTS+=" --dhcp-option=option:dns-server,${VM_NET_IP%.*}.1 --dhcp-option=option:router,${VM_NET_IP%.*}.1" + DNSMASQ_OPTS+=" --dhcp-option=option:netmask,255.255.255.0" + DNSMASQ_OPTS+=" --dhcp-option=option:router,${VM_NET_IP%.*}.1" + DNSMASQ_OPTS+=" --dhcp-option=option:dns-server,${VM_NET_IP%.*}.1" # Add DNS entry for container DNSMASQ_OPTS+=" --address=/host.lan/${VM_NET_IP%.*}.1" @@ -489,7 +495,14 @@ else closeBridge NETWORK="user" - warn "falling back to user-mode networking! Performance will be bad and port mapping will not work." + msg="falling back to user-mode networking!" + if [ ! - f "/run/.containerenv" ]; then + msg="an error occured, $msg" + else + msg="podman rootless mode detected, $msg" + fi + warn "$msg" + [ -z "$USER_PORTS" ] && info "Notice: port mapping will not work without \"USER_PORTS\" now." fi