My OpenVPN server bridges with a DHCP-serving interface and pushes "route-gateway dhcp" to clients so that the gateway and IP address will be configured using DHCP. This works great on Windows, but as everyone knows it's not supported natively on *nix systems.
So, I have an UP script for the clients that calls "ipconfig set tap0 DHCP" to configure the tap interface for DHCP. However, I've started helping out on the Tunnelblick project and I'd like to make a generic do-everything script ... that is, an UP script that recognizes when it needs to use DHCP and uses it, and recognizes when it doesn't need to use DHCP and doesn't use it, without requiring user input.
I took a look at the environmental variables available to UP scripts on the man page and saw this one:
route_vpn_gateway: The default gateway used by --route options, as specified in either the --route-gateway option or the second parameter to --ifconfig when --dev tun is specified. Set prior to --up script execution.
This seemed like a no-brainer to me. I'd test if the $route_vpn_gateway value was "dhcp" to determine if I need to use DHCP. Unfortunately, it didn't work that way. $route_vpn_gateway only has a value when the pushed/configured "route-gateway" value is an IP address. When it's set to "dhcp," $route_vpn_gateway is unset. I thought maybe "foreign_option_{n}" or some other variable might have the information I needed, but a quick printenv reveals that there are NO environmental variables available to the script that indicate DHCP should be in use.
So, my question is, is there any way (I'm not seeing it) to get the actual value of "route-gateway" (whether pushed or in the client config) from within the UP script, even if that value is "dhcp?" If not, should I file a bug that $route_vpn_gateway doesn't correctly indicate DHCP, or request that some other environmental variable (a foreign option or something like $route_gateway_dhcp) be added?
Ideas? Thoughts?
Thanks!
Nick
$route_vpn_gateway enviro. variable and "route-gateway dhcp"
Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech
-
- OpenVpn Newbie
- Posts: 12
- Joined: Thu May 12, 2011 1:57 pm
- janjust
- Forum Team
- Posts: 2703
- Joined: Fri Aug 20, 2010 2:57 pm
- Location: Amsterdam
- Contact:
Re: $route_vpn_gateway enviro. variable and "route-gateway d
it sounds like you're using a bridged setup with an external DHCP server ; in that case OpenVPN does not know the gateway, as it is provided by the DHCP server itself. The DHCPREQ & DCHPACK are processed outside of OpenVPN and hence no env var is known. You'd need to extract this information from the DHCP code, not from OpenVPN.
-
- OpenVpn Newbie
- Posts: 12
- Joined: Thu May 12, 2011 1:57 pm
Re: $route_vpn_gateway enviro. variable and "route-gateway d
Yes, I'm using a bridged setup with an external DHCP server. I know that OpenVPN doesn't know the gateway. I'm not expecting $route_vpn_gateway in the up script to contain the gateway (the UP script, after all, is the process configuring the gateway via `ipconfig set tap0 DHCP`). What I expect is for $route_vpn_gateway to be equal to the value of the "route-gateway" setting in OpenVPN. OpenVPN always knows the value of route-gateway. It's either an IP address or (in my case) the literal text value of it is set to "dhcp." You can see that in this OpenVPN-logged output below (before the UP script is called):janjust wrote:it sounds like you're using a bridged setup with an external DHCP server ; in that case OpenVPN does not know the gateway, as it is provided by the DHCP server itself. The DHCPREQ & DCHPACK are processed outside of OpenVPN and hence no env var is known. You'd need to extract this information from the DHCP code, not from OpenVPN.
Code: Select all
2011-05-01 18:36:11 PUSH: Received control message: 'PUSH_REPLY,dhcp-option DNS 172.16.122.1,route 192.168.122.0 255.255.255.0 172.16.122.1,dhcp-option DOMAIN nickhq.com,route-gateway dhcp,ping 10,ping-restart 60'
So what I'm asking is, is there some other way for me to see within the script that "route-gateway dhcp" was present or pushed, or do I need to file a bug?
Thanks
- janjust
- Forum Team
- Posts: 2703
- Joined: Fri Aug 20, 2010 2:57 pm
- Location: Amsterdam
- Contact:
Re: $route_vpn_gateway enviro. variable and "route-gateway d
I'd file it as a feature request - I'm not sure if it's absolutely needed . Isn't the *absence* of the env var enough?
-
- OpenVpn Newbie
- Posts: 12
- Joined: Thu May 12, 2011 1:57 pm
Re: $route_vpn_gateway enviro. variable and "route-gateway d
The absence of the env var very well might be enough, and if someone who knew the code well could confirm to me with 100% certainty that the only time $route_vpn_gateway is blank is when it's DHCP, I would be completely satisfied with that answer. I just don't know is the problem.janjust wrote:I'd file it as a feature request - I'm not sure if it's absolutely needed . Isn't the *absence* of the env var enough?
- janjust
- Forum Team
- Posts: 2703
- Joined: Fri Aug 20, 2010 2:57 pm
- Location: Amsterdam
- Contact:
Re: $route_vpn_gateway enviro. variable and "route-gateway d
regardless of whether the current code sets it or not, it would need to be marked as a "Feature" , so that the behaviour is documented and remains the same in the future.... I'd file it as a feature request on the Trac pages or the openvpn-devel mailing list.
-
- OpenVpn Newbie
- Posts: 12
- Joined: Thu May 12, 2011 1:57 pm
Re: $route_vpn_gateway enviro. variable and "route-gateway d
Thanks. Will do.janjust wrote:regardless of whether the current code sets it or not, it would need to be marked as a "Feature" , so that the behaviour is documented and remains the same in the future.... I'd file it as a feature request on the Trac pages or the openvpn-devel mailing list.