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.
|« Jul||Sep »|
- Android (3)
- Apple (30)
- Books (7)
- Eclipse (14)
- Errors (5)
- Firefox (7)
- Git (3)
- Hardware (18)
- Horror Code (8)
- Internet (21)
- Java (106)
- Life, universe and everything (45)
- Lifehacks (26)
- Linux (53)
- Opinions (26)
- OSX (11)
- OWNER API (3)
- Python (1)
- Software (35)
- Speeches and Conferences (8)
- Unix (5)
- Web (23)
- Windows (19)
Android apple architecture Bash bsd configuration CSS Development Düsseldorf framework free Git Google Hardware hdr How-To howto Java Karmic library Linux lion MacBook maven opensource Open Source Opinion os x OSX owner owner api patterns Pitfalls Practices properties Software TDD Testing tip tonemapped Tricks Ubuntu unix video Web