From 34ec37a00e4d2b8857b1e127477e7f504e4f2e5a Mon Sep 17 00:00:00 2001 From: Kroese Date: Thu, 27 Apr 2023 19:32:59 +0200 Subject: [PATCH] Check NET_ADMIN --- run/network.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run/network.sh b/run/network.sh index 61033ed..a7e047f 100644 --- a/run/network.sh +++ b/run/network.sh @@ -41,7 +41,11 @@ configureDHCP() { echo "INFO: Acquiring an IP address via DHCP using MAC address ${VM_NET_MAC}..." - ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge || true + if ! ip link add link "${VM_NET_DEV}" name "${VM_NET_TAP}" address "${VM_NET_MAC}" type macvtap mode bridge > /dev/null 2>&1 ; then + echo -n "ERROR: Capability NET_ADMIN has not been set. Please add the " + echo "following docker setting to your container: --cap-add NET_ADMIN" && exit 16 + fi + ip link set "${VM_NET_TAP}" up ip a flush "${VM_NET_DEV}" @@ -52,7 +56,7 @@ configureDHCP() { if [[ "${DHCP_IP}" == [0-9.]* ]]; then echo "INFO: Successfully acquired IP ${DHCP_IP} from the DHCP server..." else - echo "ERROR: Cannot acquire an IP address from the DHCP server" && exit 16 + echo "ERROR: Cannot acquire an IP address from the DHCP server" && exit 17 fi ip address flush "${VM_NET_TAP}"