Assign Static IP Address

Overview

Most hypervisors do not support extending the lease time when the IP is assigned using DHCP. This might lead to a new IP being assigned to the VM after a restart as it will conflict with the security certificates generated for the old IP. This will make Minishift completely unusable until a new instance is set up by running minishift delete followed by minishift start.

To prevent this, Minishift includes the functionality to set a static IP address to the VM. This will prevent the IP address from changing between restarts. However, it will not work on all of the driver plug-ins at the moment due to the way the IP address is resolved.

  • Assigning a static IP address to the Minishift VM is only officially supported for Hyper-V.

  • The Minishift VM cannot be assigned a static IP address when using the KVM driver plug-in.

Assign IP Address to Hyper-V

Since the Internal Virtual Switch for Hyper-V does not provide a DHCP offer option, an IP address needs to be provided in a different way. Functionality is provided to assign an IP address on startup using the Data Exchange Service for Hyper-V.

to make this work, you need to create a Virtual Switch using NAT.

WinNAT is limited to one NAT network per host. For more details about capabilities and limitations, please see the WinNAT capabilities and limitations blog.

The following command will attempt to assign an IP address for use on the Internal Virtual Switch ‘MyInternal’:

  1. PS> minishift.exe config set hyperv-virtual-switch "MyInternal"
  2. PS> minishift.exe start `
  3. --network-ipaddress 192.168.1.10 `
  4. --network-gateway 192.168.1.1 `
  5. --network-nameserver 8.8.8.8

If you want to use the ‘DockerNAT’ network, the following commands are needed to setup the correct NAT networking and assign an IP in the range expected:

  1. PS> New-NetNat -Name SharedNAT -InternalIPInterfaceAddressPrefix 10.0.75.1/24
  2. PS> minishift.exe config set hyperv-virtual-switch "DockerNAT"
  3. PS> minishift.exe start `
  4. --network-ipaddress 10.0.75.128 `
  5. --network-gateway 10.0.75.1 `
  6. --network-nameserver 8.8.8.8

Be sure to specify a valid gateway and nameserver. Failing to do so will result in connectivity issues.

Set Fixed IP Address

This feature is not supported on KVM as the driver plug-in relies on the DHCP offer to determine the IP address.

The following command will set the IP address that was assigned as fixed:

  1. $ minishift ip --set-static

If you prefer to use dynamic assignment, you can use:

  1. $ minishift ip --set-dhcp

Use minishift config set static-ip false to stop assign the static ip automatically for supported hypervsiors.