Method: VagrantWindows::Communication::GuestNetwork#configure_static_interface

Defined in:
lib/vagrant-windows/communication/guestnetwork.rb

#configure_static_interface(nic_index, net_connection_id, ip, netmask) ⇒ Object

Configures the specified interface using a static address

Parameters:

  • The (Integer)

    interface index.

  • The (String)

    unique name of the NIC, such as ‘Local Area Connection’.

  • The (String)

    static IP address to assign to the specified NIC.

  • The (String)

    network mask to use with the static IP.



63
64
65
66
67
68
# File 'lib/vagrant-windows/communication/guestnetwork.rb', line 63

def configure_static_interface(nic_index, net_connection_id, ip, netmask)
  @logger.info("Configuring NIC #{net_connection_id} using static ip #{ip}")
  #netsh interface ip set address "Local Area Connection 2" static 192.168.33.10 255.255.255.0
  netsh = "netsh interface ip set address \"#{net_connection_id}\" static #{ip} #{netmask}"
  @winrmshell.powershell(netsh)
end