Scenic
SO Windows 7
I need to connect to a remote host through cisco vpn. Sometimes the host destination network is the same as the local network. Example (partial output from ipconfig command):
Ethernet adapter Cisco Vpn Adapter:
IPv4 Address. . . . . . . . . . . : 192.168.100.12
Subnet Mask. . . . . . . . . . . : 255.255.255.0
Wireless LAN adapter Wireless Network Connection:
IPv4 Address. . . . . . . . . . . : 192.168.1.74
Subnet Mask. . . . . . . . . . . : 255.255.255.0
I need to connect to the host 192.168.1.11 on the remote network via Vpn. Then I need to add a new route (in this configuration, all traffic up to 192.168.1.xxx is the route to the local network) The result of printing the route starts with:
Interface list
17 ... 00 05 9a 3c 78 00 ...... Cisco Systems VPN Adapter
12 ... 00 16 44 ea 74 58 ...... Dell Wireless 1395 WLAN Mini-Card
And the command:
route add 192.168.1.11 mask 255.255.255.255 192.168.100.12 metric 1 if 17
Problem:
The ip on the Cisco adapter is not static, I cannot route the addition using the -p modifier (persistent). When disconnecting and reconnecting, I need to look for NewIp and add the correct route:
route add 192.168.1.11 mask 255.255.255.255 Β«NewIPΒ» metric 1 if 17
For me its easy (but boring) every time they write all these comm messages:
ipconfig etc
route print etc
route add etc
I need a bat or powershell script to add the correct route. The script looks for ip on the Cisco adapter and runs the route add command with the IP gateway base.
thanks
PD Sory my bad english
source share