Windows 10: How to set IP address using netsh but using MAC address?

mrjayviper

Weaksauce
Joined
Jul 17, 2012
Messages
91
So I have a dual port gigabit Ethernet card and I want to setup their IPs via a batch script.

I have used this and it works at the time I first wrote it.

Code:
    netsh interface ipv4 set address name="Ethernet" static 192.168.2.2 255.255.255.0
    netsh interface ipv4 set address name="Ethernet 2" static 192.168.3.2 255.255.255.0

But the problem is when I reinstalled Windows. Windows has swapped them so the IPs got swapped as well.

I am hoping to can help me with another script/command where I can use MAC address instead of "interface name" since this name can be swapped.

Thanks
 
You might want to use a different font color. One that contrasts with the background.
 
So I have a dual port gigabit Ethernet card and I want to setup their IPs via a batch script.

I have used this and it works at the time I first wrote it.

Code:
    netsh interface ipv4 set address name="Ethernet" static 192.168.2.2 255.255.255.0
    netsh interface ipv4 set address name="Ethernet 2" static 192.168.3.2 255.255.255.0

But the problem is when I reinstalled Windows. Windows has swapped them so the IPs got swapped as well.

I am hoping to can help me with another script/command where I can use MAC address instead of "interface name" since this name can be swapped.

Thanks

...just confirming for you - but I suspect you already know - this isn't going to happen.
Not in the manner you're asking. You'll need to look at alternatives to the netsh command for this.

Refer to the following official documentation:

https://technet.microsoft.com/en-us/library/cc770948(v=ws.10).aspx
(interface command reference - still current and valid for Windows 10, as per the comments at the base article for this topic).

Full technical reference for netsh - if you want it. again still valid and up to date.
https://gallery.technet.microsoft.com/netsh-technical-reference-c46523dc

...the simple issue you have is referencing via hardware address of the network adapter is not supported by netsh. look at alternatives.
Perhaps you could rename the adapters using the registry and then modify the permissions of the registry keys to prevent the names from being changed....that's one idea that springs to mind.

...good luck.
 
You know why not use DHCP and assign the mac address to a specific IP on the DHCP server? Sounds like it would be FAR easier.
 
Back
Top