Skip to contentSkip to conversation

route / route-ipv6 can not be used in ccd

Openvpn-devel Samuel Thibault 4 participants 13 messages Feb 8, 2016 – Feb 10, 2016

lore
Share & tools
lore
#0 lore raw

Hello,

Is there a reason for not being allowed to set route / route-ipv6 options in the ccd?

Here is our need: we have two openvpn daemons running on the same server, one in udp mode, the other in tcp mode. Both have the same configuration, that setup is meant for our users to use whichever happens to be working from their network, preferring udp whenever possible. The server thus has tun0 and tun1. Our users may have some additional IPs routed to them, so we record these in the ccd files, for instance:

iroute-ipv6 2a01:474:5:100::/56
route-ipv6 2a01:474:5:100::/56

However, while iroute-ipv6 is accepted by openvpn, route-ipv6 is not accepted:

samuel.thibault/::ffff:83.200.171.86 Options error: option 'route-ipv6' cannot be used in this context

The problem is that since one can not know in advance which openvpn daemon users will connect to (and thus which of tun0 or tun1 should have the route), we can not set these routes statically before the users connect.

We could of course use the --up script to set the routes, but it looks much simpler and straightforward to set it from the ccd, since we need to set the iroute there already anyway.

Samuel

#1 lore raw
Quoted 1 line · Samuel Thibault, on Mon 08 Feb 2016 22:39:29 +0100, wrote:

We could of course use the --up script to set the routes,

Oops, sorry, I didn't mean --up, but client-connect of course.

Samuel

#2 lore raw
In reply to Samuel Thibault

Hi,

Quoted 2 lines · Samuel Thibault

Is there a reason for not being allowed to set route / route-ipv6 options in the ccd?

"Nobody has implemented it yet" - plain and simple...

So - someone would need to implement this (including route/route-ipv6 cleanup at client disconnect), someone else needs to review and test it...

I've run into this myself and cursed - and then used --client-connect to achieve the same result (if not exactly pretty). Alternatively, using --learn-address might actually be much easier than --client-connect, as it will already tell you which networks are "new for this client" - from the description, I'm fairly sure it handles iroute/iroute-ipv6 as well, but for whatever reason I've never actually used this combination... (I use --learn-address to enable statically-addressed clients to connect to different OpenVPN processes, but these do not have subnets routed)

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#3 lore raw
Quoted 5 lines · Gert Doering, on Tue 09 Feb 2016 10:28:21 +0100, wrote:
Quoted 2 lines · Samuel Thibault

Is there a reason for not being allowed to set route / route-ipv6 options in the ccd?

"Nobody has implemented it yet" - plain and simple...

Ok :)

Samuel

#4 lore raw

Hi,

Quoted 8 lines · Samuel Thibault
Quoted 5 lines · Gert Doering, on Tue 09 Feb 2016 10:28:21 +0100, wrote:
Quoted 2 lines · Samuel Thibault

Is there a reason for not being allowed to set route / route-ipv6 options in the ccd?

"Nobody has implemented it yet" - plain and simple...

Ok :)

Could you test and report whether --learn-address does the job for you?

I think this would be a useful result to have in the list archives :-)

thanks,

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#5 lore raw

Hi,

Quoted 12 lines · Gert Doering
Quoted 6 lines · Samuel Thibault
Quoted 4 lines · Gert Doering, on Tue 09 Feb 2016 10:28:21 +0100, wrote:
Quoted 2 lines · Samuel Thibault

Is there a reason for not being allowed to set route / route-ipv6 options in the ccd?

"Nobody has implemented it yet" - plain and simple...

Ok :)

Could you test and report whether --learn-address does the job for you?

I think this would be a useful result to have in the list archives :-)

a 'learn-address' script is an entirely different beast than a 'client-connect' script: you cannot write out new openvpn directives in a 'learn-address' script. In both a 'client-connect' script (not a CCD file) and in a 'learn-address' script you can add routes to the system routing table provided that you're not running with "user nobody" - it's just that you cannot use the "normal" openvpn stuff for this.

JJK

#7 lore raw
In reply to Gert Doering
Quoted 11 lines · Gert Doering, on Tue 09 Feb 2016 11:46:25 +0100, wrote:
Quoted 8 lines · Samuel Thibault
Quoted 5 lines · Gert Doering, on Tue 09 Feb 2016 10:28:21 +0100, wrote:
Quoted 2 lines · Samuel Thibault

Is there a reason for not being allowed to set route / route-ipv6 options in the ccd?

"Nobody has implemented it yet" - plain and simple...

Ok :)

Could you test and report whether --learn-address does the job for you?

I have tried putting

iroute-ipv6 2a01:474:5:1100::/56

in the ccd, but from the learn-address script the environment does not contain this route.

Samuel

#6 lore raw
In reply to Jan Just Keijser

Hi,

Quoted 8 lines · Jan Just Keijser
Quoted 1 line

Could you test and report whether --learn-address does the job for you?

a 'learn-address' script is an entirely different beast than a 'client-connect' script: you cannot write out new openvpn directives in a 'learn-address' script. In both a 'client-connect' script (not a CCD file) and in a 'learn-address' script you can add routes to the system routing table provided that you're not running with "user nobody" - it's just that you cannot use the "normal" openvpn stuff for this.

The main difference (in relevance to this thread) is that --learn-address will *tell* the script what routes might be required for a specific client, while --client-connect would have to do some sort of database lookup...

Or are iroutes exported? Manpage doesn't mention anything in that regard.

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#8 lore raw
In reply to Samuel Thibault

Hi,

Quoted 6 lines · Samuel Thibault

I have tried putting

iroute-ipv6 2a01:474:5:1100::/56

in the ccd, but from the learn-address script the environment does not contain this route.

--learn-address cmd
Run command cmd to validate client virtual addresses or routes.
...
Three arguments will be appended to any arguments in cmd as fol- lows:

[1] operation -- "add", "update", or "delete" based on whether or not the address is being added to, modified, or deleted from OpenVPN's internal routing table.
[2] address -- The address being learned or unlearned. This can be an IPv4 address such as "198.162.10.14", an IPv4 subnet such as "198.162.10.0/24", or an ethernet MAC address (when --dev tap is being used) such as "00:FF:01:02:03:04".
...

"it's not in the environment" :-)

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
#9 lore raw
Quoted 5 lines · Gert Doering, on Tue 09 Feb 2016 12:58:26 +0100, wrote:
Quoted 4 lines · Samuel Thibault

I have tried putting

iroute-ipv6 2a01:474:5:1100::/56

Quoted 8 lines
Quoted 2 lines

in the ccd, but from the learn-address script the environment does not contain this route.

--learn-address cmd
Run command cmd to validate client virtual addresses or routes.
...
Three arguments will be appended to any arguments in cmd as fol- lows:

D'oh.

Busy people talking to busy people :) I didn't even take the time to check that, sorry.

I indeed see the learn-address script called with

add 2a01:474:5:1100::/56 samuel.thibault.test

And seen it called with

delete 2a01:474:5:1100::/56 samuel.thibault.test

2 minutes after the client disconnected, which would probably be fine enough for our use case.

Thanks,
Samuel

#12 lore raw
In reply to Gert Doering

Hello,

Quoted 5 lines · Gert Doering, on Tue 09 Feb 2016 10:28:21 +0100, wrote:

Alternatively, using
--learn-address might actually be much easier than --client-connect, as it will already tell you which networks are "new for this client" - from the description, I'm fairly sure it handles iroute/iroute-ipv6 as well, but for whatever reason I've never actually used this combination...

That works indeed:

#!/bin/bash

add_del="$1"
route="$2"
cname="$3"

case "$route" in

	*:*) six=-6 ;;
        *)   six="" ;;

esac

if [ -n "$dev" ]
then
device="dev $dev"
else
device=""
fi

ip $six route "$add_del" "$route" $device

Samuel

#10 lore raw
In reply to Samuel Thibault
Quoted 22 lines · Samuel Thibault
Quoted 5 lines · Gert Doering, on Tue 09 Feb 2016 12:58:26 +0100, wrote:
Quoted 4 lines · Samuel Thibault

I have tried putting

iroute-ipv6 2a01:474:5:1100::/56

Quoted 8 lines
Quoted 2 lines

in the ccd, but from the learn-address script the environment does not contain this route.

--learn-address cmd
Run command cmd to validate client virtual addresses or routes.
...
Three arguments will be appended to any arguments in cmd as fol- lows:

D'oh.

Busy people talking to busy people :) I didn't even take the time to check that, sorry.

I indeed see the learn-address script called with

Quoted 9 lines

add 2a01:474:5:1100::/56 samuel.thibault.test

And seen it called with

delete 2a01:474:5:1100::/56 samuel.thibault.test

2 minutes after the client disconnected, which would probably be fine enough for our use case.

If you use --proto udp, then it can take up to --ping-reset $SEC to trigger (IIRC). You can use explicit-exit-notify to avoid this behaviour. With this option set, the client will tell the server "I'm disconnecting now", which will trigger the --learn-address script instantly.

This option is not useful in TCP mode, as explicit disconnect is part of the TCP protocol.

Signature · 3 lines
kind regards,

David Sommerseth
#11 lore raw
Quoted 5 lines · David Sommerseth, on Wed 10 Feb 2016 01:56:57 +0100, wrote:
Quoted 2 lines

2 minutes after the client disconnected, which would probably be fine enough for our use case.

If you use --proto udp, then it can take up to --ping-reset $SEC to trigger (IIRC). You can use explicit-exit-notify to avoid this behaviour.

Apparently I forgot to uncomment the option, indeed.

Samuel