How to send google or any website to default connection not vpn

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
DarKWinGTM
OpenVpn Newbie
Posts: 4
Joined: Fri Feb 24, 2017 1:19 am

How to send google or any website to default connection not vpn

Post by DarKWinGTM » Mon Apr 24, 2017 9:54 am

How to send google or any website to default connection not vpn ?

I trying to do like this but it's not bypass over vpn

FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)
ROUTE ADD %WWWGOOGLE% mask 255.255.255.255 192.168.126.2
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 google.com') DO (IF "%%p" NEQ "" set GOOGLE=%%p)
ROUTE ADD %GOOGLE% mask 255.255.255.255 192.168.126.2
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.gstatic.com') DO (IF "%%p" NEQ "" set WWWGSTATIC=%%p)
ROUTE ADD %WWWGSTATIC% mask 255.255.255.255 192.168.126.2
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 gstatic.com') DO (IF "%%p" NEQ "" set GSTATIC=%%p)
ROUTE ADD %GSTATIC% mask 255.255.255.255 192.168.126.2
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 googleapis.com') DO (IF "%%p" NEQ "" set GOOGLEAPIS=%%p)
ROUTE ADD %GOOGLEAPIS% mask 255.255.255.255 192.168.126.2

TinCanTech
OpenVPN Protagonist
Posts: 11137
Joined: Fri Jun 03, 2016 1:17 pm

Re: How to send google or any website to default connection not vpn

Post by TinCanTech » Mon Apr 24, 2017 12:14 pm

What does the script output ?

TiTex
OpenVPN Super User
Posts: 310
Joined: Tue Apr 12, 2011 6:22 am

Re: How to send google or any website to default connection not vpn

Post by TiTex » Mon Apr 24, 2017 5:04 pm

that doesn't look right
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 http://www.google.com') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)
will run your DO for every line the ping command outputs , i'm not sure what you're trying to do but i would replace the FOR loops with this
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com ^| FIND /I "pinging"') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)
How to send google or any website to default connection not vpn ?
i don't know what that sentence means :)

DarKWinGTM
OpenVpn Newbie
Posts: 4
Joined: Fri Feb 24, 2017 1:19 am

Re: How to send google or any website to default connection not vpn

Post by DarKWinGTM » Tue Apr 25, 2017 1:52 am

Sorry it's batch script after connected VPN via openvpn

It's mean get ip from command ping http://www.google.com and set it to WWWGOOGLE

Code: Select all

FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 http://www.google.com') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)

DarKWinGTM
OpenVpn Newbie
Posts: 4
Joined: Fri Feb 24, 2017 1:19 am

Re: How to send google or any website to default connection not vpn

Post by DarKWinGTM » Tue Apr 25, 2017 2:30 am

Sorry it's batch script after connected VPN via openvpn

It's mean get ip from command ping http://www.google.com and set it to WWWGOOGLE

Code: Select all

FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)

I trying to connect vpn and except specific website connect through default internet connection not vpn
If i put this config it mean conect google.* in defult internet connection ?

Code: Select all

# redirect a host using a domainname to NOT go via the VPN
route www.google.ca 255.255.255.255 net_gateway
Refer : https://serverfault.com/questions/63103 ... ip-filteri

So it's posible to do it in batch command(Route) in windows or not , and how to do


Thanks , best regard

TiTex
OpenVPN Super User
Posts: 310
Joined: Tue Apr 12, 2011 6:22 am

Re: How to send google or any website to default connection not vpn

Post by TiTex » Tue Apr 25, 2017 6:22 am

i know what the batch script does ... i just wasn't sure what you are trying to do
so the answer is yes , try this
forget about up/down parameters , i always have issues with those on windows
lets say you have a config named myconfig.ovpn , create a batch file myconfig_up.bat in the same location where your config is with the following content

Code: Select all

@echo off
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com ^| FIND /I "pinging"') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)
route add %WWWGOOGLE% mask 255.255.255.255 192.168.126.2
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com ^| FIND /I "pinging"') DO (IF "%%p" NEQ "" set GOOGLE=%%p)
route add %GOOGLE% mask 255.255.255.255 192.168.126.2
echo @echo off > hyperion_down.bat
echo route delete %WWWGOOGLE% >> myconfig_down.bat
echo route delete %GOOGLE% >> myconfig_down.bat
this will generate myconfig_down.bat , to delete the routes when you disconnect the VPN
be sure to replace myconfig_ with the name of your config , and also run openvpn as administrator even version 2.4

DarKWinGTM
OpenVpn Newbie
Posts: 4
Joined: Fri Feb 24, 2017 1:19 am

Re: How to send google or any website to default connection not vpn

Post by DarKWinGTM » Tue Apr 25, 2017 7:38 am

TiTex wrote:i know what the batch script does ... i just wasn't sure what you are trying to do
so the answer is yes , try this
forget about up/down parameters , i always have issues with those on windows
lets say you have a config named myconfig.ovpn , create a batch file myconfig_up.bat in the same location where your config is with the following content

Code: Select all

@echo off
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com ^| FIND /I "pinging"') DO (IF "%%p" NEQ "" set WWWGOOGLE=%%p)
route add %WWWGOOGLE% mask 255.255.255.255 192.168.126.2
FOR /F "tokens=1,2 delims=[]" %%o IN ('ping -n 1 www.google.com ^| FIND /I "pinging"') DO (IF "%%p" NEQ "" set GOOGLE=%%p)
route add %GOOGLE% mask 255.255.255.255 192.168.126.2
echo @echo off > hyperion_down.bat
echo route delete %WWWGOOGLE% >> myconfig_down.bat
echo route delete %GOOGLE% >> myconfig_down.bat
this will generate myconfig_down.bat , to delete the routes when you disconnect the VPN
be sure to replace myconfig_ with the name of your config , and also run openvpn as administrator even version 2.4
Your script is correct and it look same my scirpt but i don't want delete, I want specific website connect through default internet connection not vpn. In your batch script it's mean when vpn disconnect it will delete route right ?

TiTex
OpenVPN Super User
Posts: 310
Joined: Tue Apr 12, 2011 6:22 am

Re: How to send google or any website to default connection not vpn

Post by TiTex » Tue Apr 25, 2017 9:26 am

it looks the same but it's not the same , so try it out and we'll see after that
i can't write in more plain english than i did above , sorry :)

Post Reply