Windows – Need a script to add a second IP address to a Windows machine

nicwindows

Does anyone know how to create a .reg registry script that will add a second IP address to a machine that is called 127.0.0.2 ?

Here is the "manual" method:

  1. Go to the Control Panel > Network
    Connections Right click on the
    Local Area Connection (or
    whichever network connection you
    want to add the 2nd IP Address)
    and click Properties
  2. Click on
    Internet Protocol (TCP/IP) in the
    connection box and click properties
    Enter the first IP address in the
    properties box
  3. Click Advanced
  4. Click Add under the IP Addresses box
    and enter the information for the
    2nd IP Address
  5. Close all the
    boxes

Best Answer

You're not going to want to do this with direct manipulation of the registry. You're much better off using the netsh command to make these kinds of changes.

Assuming the NIC is named "Local Area Connection", you can do netsh interface ip "Local Area Connection" x.x.x.x y.y.y.y where x.x.x.x is the IP address and y.y.y.y is the subnet mask.