From 427726ea22b21827fad5e7d74492428493f8d65d Mon Sep 17 00:00:00 2001 From: Merith Date: Thu, 5 Jun 2025 05:46:45 +0000 Subject: [PATCH] enable DHCP on gns3 use --- Dockerfile | 4 ++-- vnc.sh | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 165f227..e4c660d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ FROM alpine:latest # Install only essential packages RUN apk add --no-cache \ - xterm bash \ - procps inetutils-telnet \ + xterm bash procps \ + iproute2 iputils \ fontconfig \ i3wm i3status diff --git a/vnc.sh b/vnc.sh index 91ee65e..136de32 100644 --- a/vnc.sh +++ b/vnc.sh @@ -1,7 +1,20 @@ #!/bin/bash +# Bring up all interfaces and request DHCP, except loopback +if [ -d /gns3 ]; then + echo "Running in GNS3 environment, setting up interfaces for DHCP..." + for iface in $(ip -o link show | awk -F': ' '{print $2}' | grep -v '^lo$'); do + echo "Bringing up interface: $iface" + ip link set "$iface" up + udhcpc -i "$iface" & + done +fi + +# Wait a moment for DHCP leases +sleep 2 + # Launch i3 window manager /usr/bin/i3 echo "i3 exited unexpectedly" -sleep infinity \ No newline at end of file +sleep infinity