-1

I want to assign a static ip address to a windows 10 virtual machine at booting time. How can I do it? For example, as in linux we can modify /etc/network/interfaces file so is there any similar way for windows 10 also?

user3460393
  • 21
  • 3
  • 6

2 Answers2

2

This is simply a radio check box in the network manager GUI screen for the particular adapter you want to configure with a static IP, or a DHCP reservation based on adapters mac address, or with the netsh command line tool, or with Powershell scripts, or with a registry entry. (so about 12 hard ways and not 1 easy way!) Coming from the Linux world - Windows rarely treats things as files, there is no file you can change for network devices, disks, monitors, iscsi connections or anything really.

These will persist through a reboot.

Powershell.

$IP = "10.10.10.10"
$MaskBits = 24 # This means subnet mask = 255.255.255.0
$Gateway = "10.10.10.1"
$Dns = "10.10.10.100"
$IPType = "IPv4"

# Retrieve the network adapter that you want to configure
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}

# Remove any existing IP, gateway from our ipv4 adapter
If (($adapter | Get-NetIPConfiguration).IPv4Address.IPAddress) {
    $adapter | Remove-NetIPAddress -AddressFamily $IPType -Confirm:$false
}

If (($adapter | Get-NetIPConfiguration).Ipv4DefaultGateway) {
    $adapter | Remove-NetRoute -AddressFamily $IPType -Confirm:$false
}

 # Configure the IP address and default gateway
$adapter | New-NetIPAddress `
    -AddressFamily $IPType `
    -IPAddress $IP `
    -PrefixLength $MaskBits `
    -DefaultGateway $Gateway

# Configure the DNS client server IP addresses
$adapter | Set-DnsClientServerAddress -ServerAddresses $DNS

netsh

netsh interface ip set address name=”Local Area Connection” static 192.168.0.1 255.255.255.0 192.168.0.254

Or see here for a registry change

https://superuser.com/questions/455678/which-file-contains-the-local-static-ip-address-in-windows-xp

Sum1sAdmin
  • 1,934
  • 1
  • 12
  • 20
1

See Howtogeek: How to Assign a Static IP Address in Windows 7, 8, 10, XP, or Vista

  • In the Local Area Connection Properties window highlight Internet Protocol Version 4 (TCP/IPv4) then click the Properties button.

Local area connection properties

IP4 properties

SPRBRN
  • 571
  • 4
  • 12
  • 28