Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamralch/e6b72065616c45bf7bf23d2022146b9a to your computer and use it in GitHub Desktop.
Save iamralch/e6b72065616c45bf7bf23d2022146b9a to your computer and use it in GitHub Desktop.
Resets virtualbox DHCP leases to ensure that minikube will always take a specific IP.
#!/usr/bin/env bash
function minikube_reset_vbox_dhcp_leases() {
# Check OS version
case $OSTYPE in
darwin*)
VBOX_CONFIG_DIR=Library
;;
linux*)
VBOX_CONFIG_DIR=.config
;;
esac
# # Reset Virtualbox DHCP Lease Info
echo "Resetting Virtualbox DHCP Lease Info..."
kill -9 $(ps aux |grep -i "vboxsvc\|vboxnetdhcp" | awk '{print $2}') 2>/dev/null
if [[ -f ~/$VBOX_CONFIG_DIR/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases ]] ; then
rm ~/$VBOX_CONFIG_DIR/VirtualBox/HostInterfaceNetworking-vboxnet0-Dhcpd.leases
fi
}
minikube_reset_vbox_dhcp_leases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment