]> git.sven.stormbind.net Git - sven/scripts.git/blobdiff - home/fix-vbox-net.sh
add a workaround to bring up lokal host only virtualbox interfaces
[sven/scripts.git] / home / fix-vbox-net.sh
diff --git a/home/fix-vbox-net.sh b/home/fix-vbox-net.sh
new file mode 100755 (executable)
index 0000000..bc58a85
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+VBoxManage list hostonlyifs |
+    while IFS= read -r line; do
+       if [[ ${line} =~ ^Name ]]; then
+           lastIf=$(echo ${line} | cut -d' ' -f 2)
+       fi
+
+       if [[ ${line} =~ ^IPAddress ]]; then
+           lastIfIP=$(echo ${line} | cut -d' ' -f 2)
+       fi
+
+       if [[ ${line} =~ ^NetworkMask ]]; then
+           lastIfNetM=$(echo ${line} | cut -d' ' -f 2)
+           sudo ip link set up dev ${lastIf}
+           sudo ip a a ${lastIfIP}/${lastIfNetM} dev ${lastIf}
+           unset -v lastIf lastIfIP lastIfNetM
+       fi
+    done