This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14190|Reply: 0

[Source] Windows batch connection VPN modifies the routing table

[Copy link]
Posted on 10/2/2016 7:28:50 AM | | |

Using a BAT script to implement one-click dialing and adding routes.

1. Create a VPN dial-up connection for PPTP.

2. Right-click on a connection that has just been built – Properties – Network – Internet Protocol Version 4 – Properties – Advanced, and check off "Use default gateway on remote network" in IP settings.

@echo off

rasdial "vpn name" vpn username vpn password

ipconfig |find /i "10.0." >check.txt

for /f "tokens=2 delims=:" %%i in (check.txt) do echo %%i>check.txt

for /f "tokens=1 delims= " %%I in (check.txt) do set myip=%%I

echo your current VPN IP address is %myip%

echo y|del check.txt

route add 64.18.0.0 mask 255.255.240.0 %myip%

route add 64.233.160.0 mask 255.255.224.0 %myip%

route add 66.102.0.0 mask 255.255.240.0 %myip%

route add 66.249.80.0 mask 255.255.240.0 %myip%

route add 72.14.192.0 mask 255.255.192.0 %myip%

route add 74.125.0.0 mask 255.255.0.0 %myip%

route add 173.194.0.0 mask 255.255.0.0 %myip%

route add 207.126.144.0 mask 255.255.240.0 %myip%

route add 209.85.128.0 mask 255.255.128.0 %myip%

route add 216.58.192.0 mask 255.255.224.0 %myip%

route add 216.239.32.0 mask 255.255.224.0 %myip%

pause



1. The "10.0." in the third line is the IP address you get after a successful VPN connection, generally only the first two digits are written, if you don't know, connect manually once, and then check the IP you obtained.

2. The fourth line and the back are which network segments you need to take the VPN tunnel, if you don't fill in it, you will take the local route, I fill in the network block used by Google, that is, the server IP of Google is blocked, and it will be OK to modify it according to the actual situation.

Execute this batch when you're done. After batch processing, all IPs going to Google will go to VPN, and all other addresses will follow the default route.

Also attached is a method to obtain Google IP

nslookup -q=TXT _netblocks.google.com 8.8.8.8

How about it, is it that you don't have to worry about not being able to open Google in the future, the most important thing is that you will not use the VPN to access other resources.




Previous:Highcharts stacked histograms with drill-down functionality
Next:Why can't you do without Stackoverflow?
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com