winse@DESKTOP-ADH7K1Q:~/bigendian$ cat VPN-Route.bat
@setlocal enableextensions enabledelayedexpansion
@echo on
rem https://community.teamviewer.com/t5/Knowledge-Base/Are-there-parameters-to-start-TeamViewer/ta-p/4135
rem teamviewer.exe -i <ID> -P <Password> [-m fileTransfer/vpn]
start "teamviewer" "C:\Program Files (x86)\TeamViewer\TeamViewer.exe"
set teamvpnipaddr=7.138.125.65
:loop
ping -n 1 !teamvpnipaddr! | find "TTL"
if not errorlevel 1 goto :run
if errorlevel 1 goto :endloop
:endloop
ping -n 2 127.0.0.1 >nul: 2>nul:
cls
goto :loop
:run
route delete 192.168.193.0
route add 192.168.193.0 mask 255.255.255.0 !teamvpnipaddr! metric 1
endlocal
pause
参考的原文:
1234567891011121314151617181920
Hello everybody, I investigated a lot for this issue.
Establish a VPN session with TeamViewer to my home pc (remote side) and try to get access to this local network from my working place (local side).
I found an solution i never read anywhere before. Since Windows 7 has removed NAT option using netsh it is difficult to solve it with windows on board tools only.
- Install TeamViewer incl. VPN driver on both sides, activate unattended access on the remote side (my home pc). Use the button Show advanced options, and go to Advanced network options … Install VPN driver
- Install WinPkFilter Device Driver on remote side (my home pc) and restart (http://www.nat32.com/v2/install.htm Download installer: http://www.ntkernel.com/downloads/winpkflt_rtl.zip . NAT32 you don't need. This WinPkFilter package contains a simple GUI to configure the NAT between the VPN interface (client) and the remote side LAN interface (provider). see following hints ...
- Windows: Start RemoteAccess - service 'Routing an Remote Access' and set to automatic (local/remote side).
- Optional: On the remote side (my home pc), the registry has to be modified. Start the registry editor for example by Regedt32, and browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters Set the parameter IPEnableRouter to “1”. Using console or batch as admin: reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" /v "IPEnableRouter" /t REG_DWORD /d "1". On my system it worked without this option, but according internet forums it seems to be recommended.
- Now create a remote desktop session to your home pc and start also the VPN connection within this TeamViewer session (Menu / Extras / VPN). I created a free TeamViewer account and added all pc's to my computers to make the access to my machines easier.
- On remode side (my home pc) where WinPkFilter is installed start the Internet Gateway GUI of WinPkFilter: Start / Programms / WinpkFilter / Internet Gateway. Select (double click) the ethernet adapter of your local privat lan and set NAT Status to 'Provider'. Select the TeamViewer VPN adapter and set NAT Status to 'client'. Press 'Start NAT'
- On local side (my working place) Add a route to the local side (my working place) to give access to several devices that have the same subnet, add the route like this:
route add <base IP of remote devices> mask 255.255.255.0 <IP of Teamviewer VPN on remote PC>
metric 1
Example (home lan ip range: 192.168.2.x / TeamViewer VPN IP in home pc (remote side) 7.37.88.245
route add 192.168.2.0 mask 255.255.255.0 7.37.88.245 metric 1 <ENTER>
route add 192.168.2.0 mask 255.255.255.0 7.37.88.245 metric 1 -p <ENTER> (if persistent)
Do delete the route route delete 192.168.2.0
Now you should have access to your private home network. Good luck and have fun.