option suggestion (was Re: routing on windows)
A message that is not in the archive (sent off-list or not yet received): [email protected]...
Quoted 11 lines · Mathias Sundman
Hi!
Quoted 3 lines
we use our linux vpn gateway and some win2000 road warrior clients with openvpn. I would like to route all internet traffic trough our firewall from the windows clients.
I´ve been thinking about doing this too, but never accually tried it.
What you basicly need to do is:
1. Don´t set a default gateway on your ethernet adapter.
you have to set otherwise the vpn connection can't estabilished.
Quoted 13 lines
2. Add a route to your openvpn server with a /32 mask pointing to the gateway on your ethernet.
In your exampel this would be done with the following command on Win2K where w.x.y.z is the IP of your remote openvpn server, and a.b.c.254 is your local gateway.
ROUTE ADD w.x.y.z MASK 255.255.255.255 a.b.c.254
3. Setup OpenVPN as usual but also add a default gateway route to the TAP interface.
Quoted 8 lines
The reason why I havn´t tried this is because I don´t know how to solve the problem that the ROUTE command will be diffrent for each network you hook your laptop into. So if you don´t want to manually do this every time, you would need to write a little app that looks at the IP and default gateway that has been assigned by DHCP, switch to static IP and add the correct route.
Anyone that has a better solution to this?
you see exactly the problem!
on linux I can do (eg. in the up script):
----------------------------------
route add -host <remote-server-ip> dev ppp0
route del default dev ppp0
route add default dev tun0
----------------------------------
and we got it, but unfotunately on windows you can't route by interface (or to be more precise on windos the interface is defined by it's ip address even if you can specify the interface). so I'd like to suggest a new option for openvpn to be portable (like in the case of --route):
--route-internal
which do exactly as the above on all platform.
since openvpn know whcih ip address has the under the tun/tap interface.
or may it would be more better if the up script has one more (6th) paramter and the underlying interface's ip address:
-----------------------------------
cmd tun_dev tun_mtu link_mtu ifconfig_local_ip ifconfig_remote_ip underlying_ip [ init | restart ]
cmd tap_dev tap_mtu link_mtu ifconfig_local_ip ifconfig_netmask underlying_ip [ init | restart ]
-----------------------------------
and in this case on linux we cn write an up script as:
----------------------------------
route add -host $5 dev ppp0
route del default dev ppp0
route add default dev tun0
----------------------------------
while on windows
----------------------------------
route add $5 gw $6
route delete 0.0.0.0 mask 0.0.0.0 $5
route add 0.0.0.0 mask 0.0.0.0 $4
----------------------------------
does it possible? or any better solution?
Signature · 1 line
Levente "Si vis pacem para bellum!"
Quoted 65 lines · Farkas Levente
Quoted 11 lines · Mathias Sundman
Hi!
Quoted 3 lines
we use our linux vpn gateway and some win2000 road warrior clients with openvpn. I would like to route all internet traffic trough our firewall from the windows clients.
I´ve been thinking about doing this too, but never accually tried it.
What you basicly need to do is:
1. Don´t set a default gateway on your ethernet adapter.
you have to set otherwise the vpn connection can't estabilished.
Quoted 13 lines
2. Add a route to your openvpn server with a /32 mask pointing to the gateway on your ethernet.
In your exampel this would be done with the following command on Win2K where w.x.y.z is the IP of your remote openvpn server, and a.b.c.254 is your local gateway.
ROUTE ADD w.x.y.z MASK 255.255.255.255 a.b.c.254
3. Setup OpenVPN as usual but also add a default gateway route to the TAP interface.
Quoted 8 lines
The reason why I havn´t tried this is because I don´t know how to solve the problem that the ROUTE command will be diffrent for each network you hook your laptop into. So if you don´t want to manually do this every time, you would need to write a little app that looks at the IP and default gateway that has been assigned by DHCP, switch to static IP and add the correct route.
Anyone that has a better solution to this?
you see exactly the problem!
on linux I can do (eg. in the up script):
----------------------------------
route add -host <remote-server-ip> dev ppp0
route del default dev ppp0
route add default dev tun0
----------------------------------
and we got it, but unfotunately on windows you can't route by interface (or to be more precise on windos the interface is defined by it's ip address even if you can specify the interface).
so I'd like to suggest a new option for openvpn to be portable (like in the case of --route):
--route-internal
which do exactly as the above on all platform.
since openvpn know whcih ip address has the under the tun/tap interface. or may it would be more better if the up script has one more (6th) paramter and the underlying interface's ip address:
-----------------------------------
cmdtun_devtun_mtulink_mtuifconfig_local_ipifconfig_remote_ipunderlying_ip[ init | restart ]
cmdtap_devtap_mtulink_mtuifconfig_local_ipifconfig_netmaskunderlying_ip[ init | restart ]
-----------------------------------
and in this case on linux we cn write an up script as:
----------------------------------
route add -host $5 dev ppp0
route del default dev ppp0
route add default dev tun0
Quoted 8 lines
----------------------------------
while on windows
----------------------------------
route add $5 gw $6
route delete 0.0.0.0 mask 0.0.0.0 $5
route add 0.0.0.0 mask 0.0.0.0 $4
----------------------------------
does it possible? or any better solution?
When you say "underlying_ip" I assume you mean the original default gateway (before the up script (might have) changed it)?
I agree that it would be useful to provide an "original default gateway" parameter to up scripts.
This would provide the support necessary to conveniently route all IP traffic through the VPN tunnel.
Unfortunately, as is often the case with network configuration, there is no standard API for doing this.
To make this work in OpenVPN, you would need to follow the model of tun.c and route.c where there is a function such as get_default_gateway that has a bunch of #ifdefs for each platform.
If you want this to work on Windows right now, I would suggest you run "route print" in your up script and pipe the output to a program which parses out the "default gateway" information and returns it to the script.
Then you can do the little routing dance where you route the VPN endpoint to the original default gateway, then reset the default gateway to point to the TAP adapter.
James
Quoted 74 lines · James Yonan
Quoted 61 lines · Farkas Levente
Quoted 11 lines · Mathias Sundman
Hi!
Quoted 3 lines
we use our linux vpn gateway and some win2000 road warrior clients with openvpn. I would like to route all internet traffic trough our firewall from the windows clients.
I´ve been thinking about doing this too, but never accually tried it.
What you basicly need to do is:
1. Don´t set a default gateway on your ethernet adapter.
you have to set otherwise the vpn connection can't estabilished.
Quoted 13 lines
2. Add a route to your openvpn server with a /32 mask pointing to the gateway on your ethernet.
In your exampel this would be done with the following command on Win2K where w.x.y.z is the IP of your remote openvpn server, and a.b.c.254 is your local gateway.
ROUTE ADD w.x.y.z MASK 255.255.255.255 a.b.c.2543. Setup OpenVPN as usual but also add a default gateway route to the TAP interface.
Quoted 8 lines
The reason why I havn´t tried this is because I don´t know how to solve the problem that the ROUTE command will be diffrent for each network you hook your laptop into. So if you don´t want to manually do this every time, you would need to write a little app that looks at the IP and default gateway that has been assigned by DHCP, switch to static IP and add the correct route.
Anyone that has a better solution to this?
you see exactly the problem!
on linux I can do (eg. in the up script):
----------------------------------
route add -host <remote-server-ip> dev ppp0
route del default dev ppp0
route add default dev tun0
----------------------------------
and we got it, but unfotunately on windows you can't route by interface (or to be more precise on windos the interface is defined by it's ip address even if you can specify the interface). so I'd like to suggest a new option for openvpn to be portable (like in the case of --route):
--route-internal
which do exactly as the above on all platform.
since openvpn know whcih ip address has the under the tun/tap interface.
or may it would be more better if the up script has one more (6th) paramter and the underlying interface's ip address:
-----------------------------------
cmdtun_devtun_mtulink_mtuifconfig_local_ipifconfig_remote_ipunderlying_ip[ init | restart ]
cmdtap_devtap_mtulink_mtuifconfig_local_ipifconfig_netmaskunderlying_ip[ init | restart ]
-----------------------------------
and in this case on linux we cn write an up script as:
----------------------------------
route add -host $5 dev ppp0
route del default dev ppp0
route add default dev tun0Quoted 8 lines
----------------------------------
while on windows
----------------------------------
route add $5 gw $6
route delete 0.0.0.0 mask 0.0.0.0 $5
route add 0.0.0.0 mask 0.0.0.0 $4
----------------------------------
does it possible? or any better solution?
Quoted 5 lines
When you say "
underlying_ip" I assume you mean the original default gateway (before the up script (might have) changed it)?I agree that it would be useful to provide an "original default gateway" parameter to up scripts.
yes.
Quoted 6 lines
This would provide the support necessary to conveniently route all IP traffic through the VPN tunnel.
Unfortunately, as is often the case with network configuration, there is no standard API for doing this.
Quoted 7 lines
To make this work in OpenVPN, you would need to follow the model of
tun.candroute.cwhere there is a function such asget_default_gatewaythat has a bunch of #ifdefs for each platform.If you want this to work on Windows right now, I would suggest you run "route print" in your up script and pipe the output to a program which parses out the "default gateway" information and returns it to the script.
that's what I wouldn't like to! if openvpn already contains this code (get_default_gateway) and you knoe that this is very difficult to find out than why openvpn provide it for us? that would be a big help!
thanks in advace:-)
Quoted 3 lines
Then you can do the little routing dance where you route the VPN endpoint to the original default gateway, then reset the default gateway to point to the TAP adapter.
that's the easier part if we already know it.
Signature · 1 line
Levente "Si vis pacem para bellum!"
Quoted 103 lines · Farkas Levente
Quoted 80 lines · James Yonan
Quoted 67 lines · Farkas Levente
Quoted 11 lines · Mathias Sundman
Hi!
Quoted 3 lines
we use our linux vpn gateway and some win2000 road warrior clients with openvpn. I would like to route all internet traffic trough our firewall from the windows clients.
I´ve been thinking about doing this too, but never accually tried it.
What you basicly need to do is:
1. Don´t set a default gateway on your ethernet adapter.
you have to set otherwise the vpn connection can't estabilished.
Quoted 13 lines
2. Add a route to your openvpn server with a /32 mask pointing to the gateway on your ethernet.
In your exampel this would be done with the following command on Win2K where w.x.y.z is the IP of your remote openvpn server, and a.b.c.254 is your local gateway.
ROUTE ADD w.x.y.z MASK 255.255.255.255 a.b.c.2543. Setup OpenVPN as usual but also add a default gateway route to the TAP interface.
Quoted 8 lines
The reason why I havn´t tried this is because I don´t know how to solve the problem that the ROUTE command will be diffrent for each network you hook your laptop into. So if you don´t want to manually do this every time, you would need to write a little app that looks at the IP and default gateway that has been assigned by DHCP, switch to static IP and add the correct route.
Anyone that has a better solution to this?
you see exactly the problem!
on linux I can do (eg. in the up script):
----------------------------------
route add -host <remote-server-ip> dev ppp0
route del default dev ppp0
route add default dev tun0
----------------------------------
and we got it, but unfotunately on windows you can't route by interface (or to be more precise on windos the interface is defined by it's ip address even if you can specify the interface).
so I'd like to suggest a new option for openvpn to be portable (like in the case of --route):
--route-internal
which do exactly as the above on all platform.
since openvpn know whcih ip address has the under the tun/tap interface. or may it would be more better if the up script has one more (6th) paramter and the underlying interface's ip address:
-----------------------------------
cmdtun_devtun_mtulink_mtuifconfig_local_ipifconfig_remote_ipunderlying_ip[ init | restart ]
cmdtap_devtap_mtulink_mtuifconfig_local_ipifconfig_netmaskunderlying_ip[ init | restart ]
-----------------------------------
and in this case on linux we cn write an up script as:
----------------------------------
route add -host $5 dev ppp0
route del default dev ppp0
route add default dev tun0Quoted 8 lines
----------------------------------
while on windows
----------------------------------
route add $5 gw $6
route delete 0.0.0.0 mask 0.0.0.0 $5
route add 0.0.0.0 mask 0.0.0.0 $4
----------------------------------
does it possible? or any better solution?Quoted 5 lines
When you say "
underlying_ip" I assume you mean the original default gateway (before the up script (might have) changed it)?I agree that it would be useful to provide an "original default gateway" parameter to up scripts.
yes.
Quoted 6 lines
This would provide the support necessary to conveniently route all IP traffic through the VPN tunnel.
Unfortunately, as is often the case with network configuration, there is no standard API for doing this.
Quoted 7 lines
To make this work in OpenVPN, you would need to follow the model of
tun.candroute.cwhere there is a function such asget_default_gatewaythat has a bunch of #ifdefs for each platform.If you want this to work on Windows right now, I would suggest you run "route print" in your up script and pipe the output to a program which parses out the "default gateway" information and returns it to the script.
Quoted 5 lines
that's what I wouldn't like to! if openvpn already contains this code (
get_default_gateway) and you knoe that this is very difficult to find out than why openvpn provide it for us?
that would be a big help!
thanks in advace:-)
Good news. I threw together some code under a new flag called --redirect-gateway that will do the routing smarts to redirect the default gateway into the tunnel, and undo its actions on tun/tap close.
Keep in mind that there's no standard API for getting the current default gateway. That means there's yet another #if block at the bottom of route.c for each platform's version of get_default_gateway(). I've only implemented for Linux and Windows so far.
It will be out with beta13... If you are adventurous, the patch is already committed to the CVS, if you'd like to test or add support for other OSes besides Linux and Windows.
James
Quoted 141 lines
Quoted 119 lines · Farkas Levente
Quoted 8 lines · James Yonan
Quoted 5 lines · Farkas Levente
Quoted 3 lines · Mathias Sundman
Hi!
Quoted 1 line
we use our linux vpn gateway and some win2000 road warrior clients
with
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
openvpn. I would like to route all internet traffic trough our
firewall
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
from the windows clients.
I´ve been thinking about doing this too, but never accually tried
it.
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
What you basicly need to do is:
1. Don´t set a default gateway on your ethernet adapter.
you have to set otherwise the vpn connection can't estabilished.
Quoted 1 line
2. Add a route to your openvpn server with a /32 mask pointing to
the
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
gateway on your ethernet.
In your exampel this would be done with the following command on Win2K where w.x.y.z is the IP of your remote openvpn server, and a.b.c.254 is your local gateway.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
ROUTE ADD w.x.y.z MASK 255.255.255.255 a.b.c.2543. Setup OpenVPN as usual but also add a default gateway route to the TAP interface.
The reason why I havn´t tried this is because I don´t know how to
solve
Quoted 1 line
Quoted 1 line
Quoted 1 line
the problem that the ROUTE command will be diffrent for each network
you
Quoted 1 line
Quoted 1 line
Quoted 1 line
hook your laptop into. So if you don´t want to manually do this
every
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
time, you would need to write a little app that looks at the IP and default gateway that has been assigned by DHCP, switch to static IP
and
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
add the correct route.
Anyone that has a better solution to this?
Quoted 8 lines
Quoted 8 lines
you see exactly the problem!
on linux I can do (eg. in the up script):
----------------------------------
route add -host <remote-server-ip> dev ppp0
route del default dev ppp0
route add default dev tun0
----------------------------------
and we got it, but unfotunately on windows you can't route byinterface
Quoted 3 lines
Quoted 3 lines
(or to be more precise on windos the interface is defined by it's ip address even if you can specify the interface).
so I'd like to suggest a new option for openvpn to be portable (likein
Quoted 4 lines
Quoted 4 lines
the case of --route):
--route-internal
which do exactly as the above on all platform.
since openvpn know whcih ip address has the under the tun/tapinterface.
Quoted 23 lines
Quoted 13 lines
or may it would be more better if the up script has one more (6th) paramter and the underlying interface's ip address:
-----------------------------------
cmdtun_devtun_mtulink_mtuifconfig_local_ipifconfig_remote_ipunderlying_ip[ init | restart ]
cmdtap_devtap_mtulink_mtuifconfig_local_ipifconfig_netmaskunderlying_ip[ init | restart ]
-----------------------------------
and in this case on linux we cn write an up script as:
----------------------------------
route add -host $5 dev ppp0
route del default dev ppp0
route add default dev tun0Quoted 8 lines
----------------------------------
while on windows
----------------------------------
route add $5 gw $6
route delete 0.0.0.0 mask 0.0.0.0 $5
route add 0.0.0.0 mask 0.0.0.0 $4
----------------------------------
does it possible? or any better solution?Quoted 1 line
When you say "
underlying_ip" I assume you mean the original defaultgateway
Quoted 3 lines
(before the up script (might have) changed it)?
I agree that it would be useful to provide an "original default
gateway"
Quoted 1 line
parameter to up scripts.
yes.
Quoted 1 line
This would provide the support necessary to conveniently route all IP
traffic
Quoted 3 lines
through the VPN tunnel.
Unfortunately, as is often the case with network configuration, there
is no
Quoted 3 lines
standard API for doing this.
To make this work in OpenVPN, you would need to follow the model of
tun.candQuoted 1 line
route.cwhere there is a function such asget_default_gatewaythat hasa bunch
Quoted 3 lines
of #ifdefs for each platform.
If you want this to work on Windows right now, I would suggest you run
"route
Quoted 1 line
print" in your up script and pipe the output to a program which parses
Quoted 8 lines
out the
Quoted 1 line
"default gateway" information and returns it to the script.
that's what I wouldn't like to! if openvpn already contains this code (
get_default_gateway) and you knoe that this is very difficult to find out than why openvpn provide it for us?
that would be a big help!
thanks in advace:-)Good news. I threw together some code under a new flag called --redirect-gateway that will do the routing smarts to redirect the default gateway into the tunnel, and undo its actions on tun/tap close.
Keep in mind that there's no standard API for getting the current default gateway. That means there's yet another #if block at the bottom of
route.c
for each platform's version ofget_default_gateway(). I've only implemented
for Linux and Windows so far.
Quoted 3 lines
It will be out with beta13... If you are adventurous, the patch is already committed to the CVS, if you'd like to test or add support for other OSes besides Linux and Windows.
thanks!!! I'll try tomorrow.
I just make this small patch to your code to conform better to your coding style:-)
-------------------------------------
route.c 2003-11-02 11:06:46.000000000 +0100 renamed from route.c.lfarkas 2003-11-02 10:57:38.000000000 +0100 +4 -13
@@ -709,11 +709,12 @@ * to get the current default gateway. */ -#if defined(WIN32) - static bool get_default_gateway (in_addr_t *ret) { + +#if defined(WIN32) + ULONG size = 0; DWORD status;
@@ -747,14 +748,9 @@ } } } - return false; -} #elif defined(TARGET_LINUX) -static bool -get_default_gateway (in_addr_t *ret) -{ FILE *fp = fopen ("/proc/net/route", "r"); if (fp) {
@@ -794,15 +790,10 @@ } fclose (fp); } - return false; -} #else +#endif -static bool -get_default_gateway (in_addr_t *ret) -{ return false; } -#endif
-------------------------------------