Created
February 2, 2021 05:03
-
-
Save santouras/e835ddeeff916246fb01147ad01aef2e to your computer and use it in GitHub Desktop.
Fix virtualbox/minikube ipv6 issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
vm='minikube' | |
natnet='vboxipv6' | |
echo 'Fixing virtualbox/minikube IPV6 problems' | |
if ! command -v vboxmanage &> /dev/null; then | |
echo 'vboxmanage is not installed' | |
exit 1 | |
fi | |
vboxmanage list vms | grep $vm &> /dev/null | |
if [[ $? -ne 0 ]]; then | |
echo 'Could not find minikube vm!' | |
exit 1 | |
fi | |
# list natnets specifying ipv6 | |
vboxmanage natnetwork list $natnet | grep '1 network found' &> /dev/null | |
# add if not found | |
if [[ $? -ne 0 ]]; then | |
echo 'Adding IPV6 enabled nat network' | |
vboxmanage natnetwork \ | |
add --netname $natnet \ | |
--network '10.0.2.0/24' \ | |
--ipv6 on | |
fi | |
# check if minikube has ipv6 attached -> exit if attached | |
vboxmanage showvminfo $vm | grep $natnet &> /dev/null | |
if [[ $? -eq 0 ]]; then | |
echo 'Looks like IPV6 nat network is already enabled!' | |
exit 0 | |
fi | |
# stop if running | |
vboxmanage list runningvms | grep $vm &> /dev/null | |
MINIKUBE_RUNNING=$? | |
if [[ $MINIKUBE_RUNNING -eq 0 ]]; then | |
minikube stop | |
fi | |
# add | |
echo 'Adding IPV6 nat network' | |
vboxmanage modifyvm $vm --nic3 natnetwork | |
vboxmanage modifyvm $vm --nat-network3 $natnet | |
# start if was running | |
if [[ $MINIKUBE_RUNNING -eq 0 ]]; then | |
minikube start | |
fi | |
echo 'All your IPV6 problems should be resolved!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment