feat: Display nameservers (#217)

This commit is contained in:
Kroese 2025-03-18 19:20:36 +01:00 committed by GitHub
parent ea81b4751a
commit e0a5657ad5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,7 +178,7 @@ getHostPorts() {
configureUser() { configureUser() {
NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.1,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST" NET_OPTS="-netdev user,id=hostnet0,host=${VM_NET_IP%.*}.2,net=${VM_NET_IP%.*}.0/24,dhcpstart=$VM_NET_IP,hostname=$VM_NET_HOST"
local forward local forward
forward=$(getUserPorts "$USER_PORTS") forward=$(getUserPorts "$USER_PORTS")
@ -369,7 +369,13 @@ getInfo() {
if [ ! -d "/sys/class/net/$VM_NET_DEV" ]; then if [ ! -d "/sys/class/net/$VM_NET_DEV" ]; then
error "Network interface '$VM_NET_DEV' does not exist inside the container!" error "Network interface '$VM_NET_DEV' does not exist inside the container!"
error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 27 error "$ADD_ERR -e \"VM_NET_DEV=NAME\" to specify another interface name." && exit 26
fi
BASE_IP="${VM_NET_IP%.*}."
if [ "${VM_NET_IP/$BASE_IP/}" -lt "3" ]; then
error "Invalid VM_NET_IP, must end in a higher number than .3" && exit 27
fi fi
if [ -z "$MTU" ]; then if [ -z "$MTU" ]; then
@ -444,7 +450,10 @@ if [[ "$DEBUG" == [Yy1]* ]]; then
line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu" line="Host: $HOST IP: $IP Gateway: $GATEWAY Interface: $VM_NET_DEV MAC: $VM_NET_MAC MTU: $mtu"
[[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)" [[ "$MTU" != "0" ]] && [[ "$MTU" != "$mtu" ]] && line+=" ($MTU)"
info "$line" info "$line"
[ -f /etc/resolv.conf ] && grep '^nameserver*' /etc/resolv.conf if [ -f /etc/resolv.conf ]; then
nameservers=$(grep '^nameserver*' /etc/resolv.conf | head -c -1 | sed 's/nameserver //g;' | sed -z 's/\n/, /g')
[ -n "$nameservers" ] && info "Nameservers: $nameservers"
fi
echo echo
fi fi