2

I have not been able to find nothing on the netsh command shell documentation for changing only the netmask configuration without modifying rest of it (ip, gateway, DNSs and so on).
The closest I know about is this one, that changes too IP and gateway:

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

Before attemping some more serious scripting about the problem, is there any way, like using powershell, power tools, wmic, or at least with some NirSoft, PSTools or similar command-line utility?
Thanks.

1 Answers1

0

No, the correct way is to specify the IP address and gateway, as you noted above. If you're trying to connect to other networks in your address space, it would be preferred to confirm that you want the same IP address and gateway, which is why netsh expects this info.

Having said that, Powershell will let you, using the CIDR notation. If you know the Interface Index, you can use the following powershell command (as admin):

Set-NetIPAddress -InterfaceIndex x -PrefixLength y

(Replace x with the Interface Index of the interface you want to change; replace y with the CIDR length for your subnet).

To see what Interface Indexes you have (as well as your other IP settings), you can run:

Get-NetIPAddress
Canadian Luke
  • 24,640