Multiple IP on a single network interface

If you use tools like netswitcher to configure on the fly more profiles for accessing the networks from home / office / Internet Cafe you may have a look at netsh command line provided by Windows, that can do this and more weird things, like binding more IP addresses to your network interface.

For example, at home I have a WIFI access point and I don’t use DHCP. But I don’t want to expose the administration console of the access point to Internet, so I put the administration console on a different subnet that is only accessible by air if you are around it. On my laptop then I need to access the Internet subnet (192.168.125.*) routed by the access point and the Intranet subnet (10.21.35.*) to access the access-point administration console, using only my WIFI network card.
This is the script “WIFI Home Static IP.nsh” to do that:

interface ip
set address name="Wireless Network Connection" source=static addr= mask= gateway= gwmetric=0
add address name="Wireless Network Connection" addr=  mask=
set dns name="Wireless Network Connection" source=static addr=

The above script sets two IP addresses and related subnets details for the interface called “Wireless Network Connection”. The interface name comes from the Network Connections dialog of Windows.

To execute the script you use the command:
netsh -f "WIFI Home Static IP.nsh"

Executing that, this is my ipconfig output

Scheda Ethernet Wireless Network Connection:

        Suffisso DNS specifico per connessione:
        Indirizzo IP. . . . . . . . . . . . . :
        Subnet mask . . . . . . . . . . . . . :
        Indirizzo IP. . . . . . . . . . . . . :
        Subnet mask . . . . . . . . . . . . . :
        Gateway predefinito . . . . . . . . . :

And to restore the default IP settings for other networks (using DHCP for obtaining single IP and DNS) I use this other script called “WI-FI DHCP.nsh”:

interface ip
set address name="Wireless Network Connection" source=dhcp
set dns name="Wireless Network Connection" source=dhcp

The above lines sets IP and DNS address to be obtained automatically from the DHCP (that is the default behavior), for my Wireless Network Connection.

To do things quickly I associated the .nsh file extension to the command netsh -f "%1" and now I can switch network settings just clicking on an icon.

Learning to create netsh scripts can help much if you bring your laptop in different networks.

One Response to “Multiple IP on a single network interface”  

  1. 1 Paul

    This is PERFECT! I was struggling with two web servers that needed to use port 80. By using your script I can have a web server on one ip address and the other web server on the other ip address.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


August 2007
« Jul   Sep »

Follow me

twitter flickr LinkedIn feed

Subscribe by email

Enter your email address:



Tag Cloud