Needless to say, this can be incredibly monotonous and time consuming if you are adding more than a few IP addresses. Thankfully, there is a much easier way which allows you to add an entire subnet (or more) in seconds.
Adding an IP Address from the Command Line
Windows includes the “netsh” command which allows you to configure just about any aspect of your network connections. If you view the accepted parameters using “netsh /?” you will be presented with a list of commands each which have their own list of commands (and so on). For the purpose of adding IP addresses, we are interested in this string of parameters:
Note: For Windows Server 2003/XP and earlier, “ipv4” should be replaced with just “ip” in the netsh command.
If you view the help information, you can see the full list of accepted parameters but for the most part what you will be interested in is something like this:
The above command adds the IP Address 192.168.1.2 (with Subnet Mask 255.255.255.0) to the connection titled “Local Area Network”.
Adding Multiple IP Addresses at Once
When we accompany a netsh command with the FOR /L loop, we can quickly add multiple IP addresses. The syntax for the FOR /L loop looks like this:
So we could easily add every IP address from an entire subnet using this command:
This command takes about 20 seconds to run, where adding the same number of IP addresses manually would take significantly longer.
A Quick Demonstration
Here is the initial configuration on our network adapter:
Now run netsh from within a FOR /L loop to add IP’s 192.168.1.10-20 to this adapter:
After the above command is run, viewing the IP Configuration of the adapter now shows: