Multiple IP on a single network interface
1 Comment Published August 9th, 2007 in Internet, Windows Tags: .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=192.168.125.77 mask=255.255.255.0 gateway=192.168.125.1 gwmetric=0 add address name="Wireless Network Connection" addr=10.21.35.2 mask=255.255.255.0 set dns name="Wireless Network Connection" source=static addr=192.168.178.1
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. . . . . . . . . . . . . : 10.21.35.2
Subnet mask . . . . . . . . . . . . . : 255.255.255.0
Indirizzo IP. . . . . . . . . . . . . : 192.168.125.77
Subnet mask . . . . . . . . . . . . . : 255.255.255.0
Gateway predefinito . . . . . . . . . : 192.168.125.1
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.
Search
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jul | Sep » | |||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
Archives
Categories
- Android (3)
- Apple (26)
- Books (7)
- Eclipse (14)
- Errors (3)
- Firefox (7)
- Git (2)
- Hardware (16)
- Horror Code (8)
- Internet (18)
- Java (98)
- JavaScript (9)
- Life, universe and everything (45)
- Lifehacks (25)
- Linux (50)
- Opinions (25)
- OSX (4)
- Python (1)
- Software (27)
- Speeches and Conferences (8)
- Unix (3)
- Web (21)
- Windows (19)
Tag Cloud
Android apple architecture Bash colors configuration CSS Development Düsseldorf Eclipse germany Git Google Hardware hdr How-To Java JAXB job junit Karmic Linux MacBook music night Open Source Opinion oracle OSX patterns Pitfalls Practices Resume Security Software Suspend TDD Testing tip tonemapped Tricks Ubuntu video Web XML
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Blog License
Blogs I like
Books on the desk
Friends' Blogs
- Antonio Terreno & Valter Bernardini
- Bruno Bossola
- Daniele Galluccio
- Domenico Ventura
- Ed Schepis
- Fabrizio Gianneschi
- Luca Grulla
- Luigi Zanderighi
- Marcello Teodori
- Mida Boghetich
- Muralidharan Chandrasekaran
- Piero Ricca
- Renzo Borgatti
- Simone Bordet
- Simone Bruno
- Uberto Barbini
- Valvolog
- Webtide blogs (Greg Wilkins & Jan Bartel)
Links




















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.