Skip to contentSkip to conversation

Radius support (Authentification, Authorization and Accounting)

Openvpn-devel Ralf Lübben 5 participants 38 messages Apr 29, 2005 – Jun 28, 2005 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,

I am interesting in build radius support for OpenVpn. At the moment I'am thinking about what is the best way.

1. Authentification and Authroization:
I think this already works with the plugin pam_radius_auth.so, is that right?

But I am interested in more features,
like to get the ip-address and the routes from the RADIUS-Server. Can this be done with a plugin? Maybe by creating the configurationfiles at the start of the connection?
Or could this be integrated in the Source Code? I think this would be the best solution.
I hope the fea
2. Accounting:
I need to count the traffic of a VPN-connection, one the side every traffic which goes from a client to the server (tun0-interface) and one the other side every traffic which goes through the VPN, maybe from one client to another client.
So when I use the counter of the tun-interface, I lose the traffic which goes from one client to another. If I count the traffic of the eth-interface I get other traffic, which has nothing to do with the vpn.

Maybe someone has some experiences with this topic and give some hints which is the best way? To do all things in a modul or to do all changes in the source code. and where I have to look in the source code to integrate this feature.

I hope there is a gerneal interest in this feature.

For every help I am very grateful.

Ralf Lübben

#1 lore raw
Quoted 7 lines · On Fri, 29 Apr 2005, Ralf [iso-8859-1] L�bben wrote:

Hello,

I am interesting in build radius support for OpenVpn. At the moment I'am thinking about what is the best way.

1. Authentification and Authroization:
I think this already works with the plugin pam_radius_auth.so, is that right?

Yes.

Quoted 6 lines

But I am interested in more features,
like to get the ip-address and the routes from the RADIUS-Server. Can this be done with a plugin? Maybe by creating the configurationfiles at the start of the connection?
Or could this be integrated in the Source Code? I think this would be the best solution.

You should be able to do this as a plugin. OpenVPN plugins can register a number of callbacks (see openvpn-plugin.h).

You could use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY to verify user/pass, OPENVPN_PLUGIN_CLIENT_CONNECT to pass IP address and routes, and OPENVPN_PLUGIN_CLIENT_DISCONNECT to process client disconnects.

Quoted 9 lines

I hope the fea
2. Accounting:
I need to count the traffic of a VPN-connection, one the side every traffic which goes from a client to the server (tun0-interface) and one the other side every traffic which goes through the VPN, maybe from one client to another client.
So when I use the counter of the tun-interface, I lose the traffic which goes from one client to another. If I count the traffic of the eth-interface I get other traffic, which has nothing to do with the vpn.

The OPENVPN_PLUGIN_CLIENT_DISCONNECT callback (or script) can access client bandwidth info on the about-to-be-closed session by looking at the bytes_received and bytes_sent environmental variables. See the man page for more info.

James

#2 lore raw

Hello,

thank you. That solves a lot of my problems.

I have still one problem with accouting.
When a client connect, I get a ticket from the RADIUS-Server, there is given an interval, in which I must send Alive-tickets to the RADIUS-Server with the actual traffic and the time of the connection.

Can I get the data from OpenVPN during the connection?

Another question about the IP address and OPENVPN_PLUGIN_CLIENT_CONNECT. Is there a possibility to give the IP address direct to the OpenVPN process or must I create the configuration files when a client connects?

Ralf Lübben

Am Freitag, 29. April 2005 18:53 schrieb James Yonan:

Quoted 54 lines · On Fri, 29 Apr 2005, Ralf [iso-8859-1] Lübben wrote:
Quoted 8 lines

Hello,

I am interesting in build radius support for OpenVpn. At the moment I'am thinking about what is the best way.

1. Authentification and Authroization:
I think this already works with the plugin pam_radius_auth.so, is that right?

Yes.

Quoted 6 lines

But I am interested in more features,
like to get the ip-address and the routes from the RADIUS-Server. Can this be done with a plugin? Maybe by creating the configurationfiles at the start of the connection?
Or could this be integrated in the Source Code? I think this would be the best solution.

You should be able to do this as a plugin. OpenVPN plugins can register a number of callbacks (see openvpn-plugin.h).

You could use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY to verify user/pass, OPENVPN_PLUGIN_CLIENT_CONNECT to pass IP address and routes, and OPENVPN_PLUGIN_CLIENT_DISCONNECT to process client disconnects.

Quoted 9 lines

I hope the fea
2. Accounting:
I need to count the traffic of a VPN-connection, one the side every traffic which goes from a client to the server (tun0-interface) and one the other side every traffic which goes through the VPN, maybe from one client to another client.
So when I use the counter of the tun-interface, I lose the traffic which goes from one client to another. If I count the traffic of the eth-interface I get other traffic, which has nothing to do with the vpn.

The OPENVPN_PLUGIN_CLIENT_DISCONNECT callback (or script) can access client bandwidth info on the about-to-be-closed session by looking at the bytes_received and bytes_sent environmental variables. See the man page for more info.

James

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw
Quoted 10 lines · On Sat, 30 Apr 2005, Ralf [iso-8859-1] Lübben wrote:

Hello,

thank you. That solves a lot of my problems.

I have still one problem with accouting.
When a client connect, I get a ticket from the RADIUS-Server, there is given an interval, in which I must send Alive-tickets to the RADIUS-Server with the actual traffic and the time of the connection.

Can I get the data from OpenVPN during the connection?

Right now, you can only get it by reading the --status file. For 2.1 I'm considering to add another script/callback for passing current accounting data.

One of the goals of the plugin interface is to allow a fully-featured Radius plugin to be developed, as you are doing, so I would be happy to work with you on extending the plugin interface for 2.1 if you find that the current plugin API is insufficient.

Quoted 3 lines

Another question about the IP address and OPENVPN_PLUGIN_CLIENT_CONNECT. Is there a possibility to give the IP address direct to the OpenVPN process or must I create the configuration files when a client connects?

No, you have to write configuration file directives (containing the appropriate ifconfig-push directive) to the temporary file provided by the caller. This is so that we can maintain an identical interface for both script and plugin calls.

James

Quoted 67 lines

Am Freitag, 29. April 2005 18:53 schrieb James Yonan:

Quoted 45 lines · On Fri, 29 Apr 2005, Ralf [iso-8859-1] Lübben wrote:
Quoted 8 lines

Hello,

I am interesting in build radius support for OpenVpn. At the moment I'am thinking about what is the best way.

1. Authentification and Authroization:
I think this already works with the plugin pam_radius_auth.so, is that right?

Yes.

Quoted 6 lines

But I am interested in more features,
like to get the ip-address and the routes from the RADIUS-Server. Can this be done with a plugin? Maybe by creating the configurationfiles at the start of the connection?
Or could this be integrated in the Source Code? I think this would be the best solution.

You should be able to do this as a plugin. OpenVPN plugins can register a number of callbacks (see openvpn-plugin.h).

You could use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY to verify user/pass, OPENVPN_PLUGIN_CLIENT_CONNECT to pass IP address and routes, and OPENVPN_PLUGIN_CLIENT_DISCONNECT to process client disconnects.

Quoted 9 lines

I hope the fea
2. Accounting:
I need to count the traffic of a VPN-connection, one the side every traffic which goes from a client to the server (tun0-interface) and one the other side every traffic which goes through the VPN, maybe from one client to another client.
So when I use the counter of the tun-interface, I lose the traffic which goes from one client to another. If I count the traffic of the eth-interface I get other traffic, which has nothing to do with the vpn.

The OPENVPN_PLUGIN_CLIENT_DISCONNECT callback (or script) can access client bandwidth info on the about-to-be-closed session by looking at the bytes_received and bytes_sent environmental variables. See the man page for more info.

James

Quoted 9 lines

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#4 lore raw

Am Samstag, den 30.04.2005, 01:42 -0600 schrieb James Yonan:

Quoted 9 lines

Right now, you can only get it by reading the --status file. For 2.1 I'm considering to add another script/callback for passing current accounting data.

One of the goals of the plugin interface is to allow a fully-featured Radius plugin to be developed, as you are doing, so I would be happy to work with you on extending the plugin interface for 2.1 if you find that the current plugin API is insufficient.

Quoted 8 lines
Quoted 3 lines

Another question about the IP address and OPENVPN_PLUGIN_CLIENT_CONNECT. Is there a possibility to give the IP address direct to the OpenVPN process or must I create the configuration files when a client connects?

No, you have to write configuration file directives (containing the appropriate ifconfig-push directive) to the temporary file provided by the caller. This is so that we can maintain an identical interface for both script and plugin calls.

Hi James,
as I'm also working on Radius integration via a plugin, I wondered if there is the possibility to provide options for the scripts/plugins in the openvpn config.

For example, the openvpn config file could look like:
...
dev tun
pull
option key1 value1
option key2 value2

OpenVPN should then provide the scripts and plugins with the extra environment variables key1 and key2 with values value1 and value2.

This could be useful to specify script and plugin specific values like radius server ip. This would allow the plugins to be more generic as the values aren't hard coded and much simpler, as there wouldn't be the need for an separate config parsing mechanism.

greetings
leh

#7 lore raw
In reply to James Yonan

Am Samstag, den 30.04.2005, 01:42 -0600 schrieb James Yonan:
[snip]

Quoted 4 lines

No, you have to write configuration file directives (containing the appropriate ifconfig-push directive) to the temporary file provided by the caller. This is so that we can maintain an identical interface for both script and plugin calls.

Hi James,
I've just read your mail again and wondered why script and plugin have to be equal in functionality.
If there was the chance of avoiding file io, I would be much more happy.

But maybe there is another alternative. Maybe the IP adress could be the return value of the client connect script/plugin or something like that.

I'm just unhappy with creating files only to provide this little information...

greetings
leh

#5 lore raw
In reply to Daniel Lehmann
Quoted 24 lines · Daniel Lehmann

Am Samstag, den 30.04.2005, 01:42 -0600 schrieb James Yonan:

Quoted 9 lines

Right now, you can only get it by reading the --status file. For 2.1 I'm considering to add another script/callback for passing current accounting data.

One of the goals of the plugin interface is to allow a fully-featured Radius plugin to be developed, as you are doing, so I would be happy to work with you on extending the plugin interface for 2.1 if you find that the current plugin API is insufficient.

Quoted 8 lines
Quoted 3 lines

Another question about the IP address and OPENVPN_PLUGIN_CLIENT_CONNECT. Is there a possibility to give the IP address direct to the OpenVPN process or must I create the configuration files when a client connects?

No, you have to write configuration file directives (containing the appropriate ifconfig-push directive) to the temporary file provided by the caller. This is so that we can maintain an identical interface for both script and plugin calls.

Hi James,
as I'm also working on Radius integration via a plugin, I wondered if there is the possibility to provide options for the scripts/plugins in the openvpn config.

Quoted 6 lines

For example, the openvpn config file could look like:
...
dev tun
pull
option key1 value1
option key2 value2

Take a look at the "setenv" directive. The setenv list is passed to plugins.

James

#8 lore raw
In reply to Daniel Lehmann
Quoted 12 lines · Daniel Lehmann

Am Samstag, den 30.04.2005, 01:42 -0600 schrieb James Yonan:
[snip]

Quoted 4 lines

No, you have to write configuration file directives (containing the appropriate ifconfig-push directive) to the temporary file provided by the caller. This is so that we can maintain an identical interface for both script and plugin calls.

Hi James,
I've just read your mail again and wondered why script and plugin have to be equal in functionality.
If there was the chance of avoiding file io, I would be much more happy.

Quoted 5 lines

But maybe there is another alternative. Maybe the IP adress could be the return value of the client connect script/plugin or something like that.

I'm just unhappy with creating files only to provide this little information...

I agree that this method is not perfect, but it has the two important properties that:

(1) it lets OpenVPN handle script or plugin calls the same
(2) it works on all OSes, including Windows

And remember that you can also optimize out the use of disk files with something like (on Linux):

tmp-dir /dev/shm

James

#10 lore raw
In reply to James Yonan

One other possible sticking point:

If you want to handle IP address allocation through Radius, you will need to figure out a way to have Radius allocate /30 subnets rather than individual IP addresses. The current Windows TUN/TAP driver requires this when running in TUN mode (and eliminating this requirement would be a LARGE project -- see previous discussion on openvpn-users list).

Essentially, when you have your client-connect plugin return the IP addresses to use for a given client connection by adding an ifconfig-push directive to the returned temporary file, you will need to make sure that both addresses in the ifconfig-push are the two middle addresses in a /30 subnet.

On Windows:

c:\> openvpn --show-valid-subnets
On Windows, point-to-point IP support (i.e. --dev tun) is emulated by the TAP-Win32 driver. The major limitatio imposed by this approach is that the --ifconfig local and remote endpoints must be part of the same 255.255.255.252 subnet. The following list shows examples of endpoint pairs which satisfy this requirement. Only the final component of the IP address pairs is at issue.

As an example, the following option would be correct:

    --ifconfig 10.7.0.5 10.7.0.6 (on host A)
    --ifconfig 10.7.0.6 10.7.0.5 (on host B)

because [5,6] is part of the below list.

[ 1, 2] [ 5, 6] [ 9, 10] [ 13, 14] [ 17, 18]
[ 21, 22] [ 25, 26] [ 29, 30] [ 33, 34] [ 37, 38]
[ 41, 42] [ 45, 46] [ 49, 50] [ 53, 54] [ 57, 58]
[ 61, 62] [ 65, 66] [ 69, 70] [ 73, 74] [ 77, 78]
[ 81, 82] [ 85, 86] [ 89, 90] [ 93, 94] [ 97, 98]
[101,102] [105,106] [109,110] [113,114] [117,118]
[121,122] [125,126] [129,130] [133,134] [137,138]
[141,142] [145,146] [149,150] [153,154] [157,158]
[161,162] [165,166] [169,170] [173,174] [177,178]
[181,182] [185,186] [189,190] [193,194] [197,198]
[201,202] [205,206] [209,210] [213,214] [217,218]
[221,222] [225,226] [229,230] [233,234] [237,238]
[241,242] [245,246] [249,250] [253,254]

James

#9 lore raw
In reply to James Yonan

Am Samstag, den 30.04.2005, 13:33 -0600 schrieb James Yonan:

Quoted 10 lines

I agree that this method is not perfect, but it has the two important properties that:

(1) it lets OpenVPN handle script or plugin calls the same
(2) it works on all OSes, including Windows

And remember that you can also optimize out the use of disk files with something like (on Linux):

tmp-dir /dev/shm

Hi James,

I still would prefer a "cleaner" solution.
But you see the whole scope of such an decision - for me the windows support of the mentioned method is irrelevant.

Thx, for the idea of using a ram-drive. I'll give that a try. leh

#6 lore raw
In reply to James Yonan

Am Samstag, den 30.04.2005, 13:27 -0600 schrieb James Yonan:

Quoted 2 lines

Take a look at the "setenv" directive. The setenv list is passed to plugins.

Hmmm, I must have overseen this. What a luck that I haven't flamed RTFM on the list yet :-)

Maybe I've also overseen the new wiki. Did you have time to install it yet? I've struggled with openvpn several hours yesterday to find out that there where malicious routing entries on the server. I'd like to put a description of the problem and the solution in the wiki (there was already a mail on the list regarding this problem).

greetings
leh

#11 lore raw
In reply to James Yonan

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-------------------------------------------------------------------------------------------------------------
Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This attribut can occur several times in the "access-accept-ticket".

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.
- Idle-Timeout: The connection is disconnected, if there is no traffic

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval".
This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

------------------------------------------------------------------------------------------------------------
During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Questions:
Is it possible to generate the status file every second?
Is the accounting information in the status file separate for every user? Which information can I get from the status file?

------------------------------------------------------------------------------------------------------
End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Greetings
Ralf

#12 lore raw

Am Dienstag, den 03.05.2005, 13:48 +0200 schrieb Ralf Lübben:

Quoted 5 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the
ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

AFAIK for receiving a Framed-IP-Address out of a IP-Pool the Client must send a unique NAS-IP-Address:NAS-Port pair to the server, when doing the *authentication*. There must also exist a Service-Type=Framed Attribute in the Authentication Request.

I added this to ppp 2.4.1, to be able to receive a IP address from a server side pool for a PPTP connection.

This is based on the patch:

http://www.xs4all.nl/~evbergen/radius-pppd.html

I simply added the NAS-Port which is the number of the ppp-interface

[...]

        addpair(&head, &tail, "NAS-Port", 0,rad_nasport(ifname),0);

[...]

rad_nasport simply cuts out the numeric value following ppp in the interface name.

Handing out static Ips based on the clientname should work without sending a unique NAS-IP-Address:NAS-Port pair in the authentication process.

Signature · 1 line
Torge Szczepanek <[email protected]...>
#13 lore raw
In reply to Ralf Lübben
Quoted 14 lines · On Tue, 3 May 2005, Ralf [iso-8859-1] Lübben wrote:

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-------------------------------------------------------------------------------------------------------------
Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

Quoted 7 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This attribut can occur several times in the "access-accept-ticket".

You might need a split privilege model here, because adding routes requires root privileges, and for security reasons, we don't want to run the main OpenVPN process as root. The OpenVPN plugin model supports split privileges, i.e. where the plugin process holds onto root while the main OpenVPN process drops privileges (see auth-pam or down-root for examples of this), so you'd probably need to have the plugin fork a process to handle route additions.

Quoted 5 lines

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.

OpenVPN doesn't support this right now.

Quoted 1 line

- Idle-Timeout: The connection is disconnected, if there is no traffic

This is tricky, because how do you define traffic?

Quoted 2 lines

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

Good idea.

Quoted 11 lines

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval".
This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Quoted 6 lines

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY (called first) to authorize username/password and OPENVPN_PLUGIN_CLIENT_CONNECT (called next) to push IP address and routes to client.

Quoted 2 lines

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

With 2.0.x, OpenVPN is running in a single thread, so plugin callbacks will stall the whole process.

For 2.1, there will be multithread support (two threads actually), so calls to plugins will occur from a different thread than the main packet forwarding thread. There will only be a single thread for calling plugins, so you won't need to make the plugin callbacks themselves reentrant.

Quoted 11 lines

------------------------------------------------------------------------------------------------------------
During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

This would work, but it might be cleaner for OpenVPN 2.1 to add a new callback for passing accounting data to the plugin.

The problem with polling the status file is that there's no guarantee of change atomicity, i.e. an entry could be added and then deleted from the file between pollings.

Quoted 16 lines

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Quoted 2 lines

Questions:
Is it possible to generate the status file every second?

Yes, however if the OpenVPN event loop is not actively forwarding packets, the status file update interval could be as long as 10 seconds.

Quoted 1 line

Is the accounting information in the status file separate for every user?

Yes.

Quoted 1 line

Which information can I get from the status file?

For each client:

Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since

For each internal routing table entry:

Virtual Address,Common Name,Real Address,Last Reference

Quoted 15 lines

------------------------------------------------------------------------------------------------------
End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Quoted 6 lines

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Yes, but sometimes there is a delay on UDP disconnects, since UDP is connectionless, so the call to PLUGIN_CLIENT_DISCONNECT might occur more than 1 minute after the actual disconnection. Also, with UDP, if a client disconnects and immediately reconnects using the same port number (if nobind isn't used on the client), the server will see both the original connection and the reconnect as being part of the same connection, so there won't be a call to PLUGIN_CLIENT_DISCONNECT then PLUGIN_CLIENT_CONNECT.

James

#14 lore raw

Hello,

I finished a C++class for the radius protocol. So I can send, receive and analyze authentication and accounting radius packets.

Now I will start to create the openvpn-plugin.

I have there still some quesitions:

When are called the funktions:
openvpn-plugin_open_v1
openvpn-plugin_func_v1
openvpn-plugin_close_v1

Is this right?
- openvpn-plugin_open_v1: At the start of openvpn.
- openvpn-plugin_func_v1: When the event happens.
- openvpn-plugin_close_v1: When openvpn is closed.

To communicate between the functions I can create
a user-defined struct, which can be shared between the functions over the openvpn_plugin_handle_t. Is that also right?

I want divide the hole plugin in two parts:

1. Authorisation and Authentification
This will work like the auth-pam-plugin (split privilege execution model) only with radius support. The plugin-process holds root rights, so routes from the radius server can be set.

I want to send following attribute:
Username
Password
NAS-Port = number of the tun interface
NAS-IP-Address = ip address of the openvpn server
NAS-Identifier = user defined string

I want to analyze following attributes of the radius response:
Framed-Route = set to the server routing table and
write to the client file in client-config-dir with the iroute directive
Framed-IP-Address = write to the client file in the client-config-dir
with the (ifconfig Framed-IP IP2) directive, the other point (IP2)
must be create maybe by (IP2+1).
Acct-Interim-Interval = the accounting interval

(Maybe later a vendor specific attributs for routes which can be pushed to the client=

The Framed-Route and the Framed-IP-Address will be written to a file with the name of the enviroment variable envp[common-name]. At the end of a connection the routes should be deleted.

If a client disconnect, the iroutes in the OpenVpn-process are deleted automatically?

2. Accounting
Here I'm not sure, want is the best way to do it, maybe somebody have some ideas.
One idea is to create for every openvpn-client who connects to the openvpn-server a own process with fork(). So every process gets his own Acct-Interim-Interval and can send the accounting data to the radius server. The data is read from the status file. This file must be accessible by the user (nobody) of the openvpn process.
If there are a lot of users, there are a lot of processes and every process reads the status file.

The other idea is to create only one process which handles all accounting, this process will work like the auth-pam-plugin (split privilege execution model). This process must schedule the differnt Acct-Interim-Intervals of the clients. The data is read from
the status file.

Accounting Attributes:
Acct-Status-Type:
start - at the beginning of the connection update - during the connection
stop - at the end
NAS-Session-ID: unique for a connection
NAS-Identidier: user-defined value
Acct-Input-Octets: read from the status file
Acct-Output-Octets: read from the status file
Acct-Session-Time: intenal counter or read from the status file

The accounting stop ticket can only be send by the disconnect plugin. Can I share informations between plugins? So the disconnect plugin can send a disconnect signal to the accounting process, maybe over a socket? So the accounting for this users stopps and the ticket is generated.

Maybe someone has additional ideas.

Greetings
Ralf

support

Quoted 182 lines · James Yonan
Quoted 14 lines · On Tue, 3 May 2005, Ralf [iso-8859-1] Lübben wrote:

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-----------------------------------------------------------------------
Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

Quoted 8 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This
attribut can occur several times in the "access-accept-ticket".

You might need a split privilege model here, because adding routes requires root privileges, and for security reasons, we don't want to run the main OpenVPN process as root. The OpenVPN plugin model supports split privileges, i.e. where the plugin process holds onto root while the main OpenVPN process drops privileges (see auth-pam or down-root for examples of this), so you'd probably need to have the plugin fork a process to handle route additions.

Quoted 5 lines

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.

OpenVPN doesn't support this right now.

Quoted 1 line

- Idle-Timeout: The connection is disconnected, if there is no traffic

This is tricky, because how do you define traffic?

Quoted 3 lines

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

Good idea.

Quoted 12 lines

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval". This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Quoted 6 lines

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY (called first) to authorize username/password and OPENVPN_PLUGIN_CLIENT_CONNECT (called next) to push IP address and routes to client.

Quoted 2 lines

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

With 2.0.x, OpenVPN is running in a single thread, so plugin callbacks will stall the whole process.

For 2.1, there will be multithread support (two threads actually), so calls to plugins will occur from a different thread than the main packet forwarding thread. There will only be a single thread for calling plugins, so you won't need to make the plugin callbacks themselves reentrant.

Quoted 11 lines

---------------------------------------------------------------
During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

This would work, but it might be cleaner for OpenVPN 2.1 to add a new callback for passing accounting data to the plugin.

The problem with polling the status file is that there's no guarantee of change atomicity, i.e. an entry could be added and then deleted from the file between pollings.

Quoted 17 lines

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Quoted 2 lines

Questions:
Is it possible to generate the status file every second?

Yes, however if the OpenVPN event loop is not actively forwarding packets, the status file update interval could be as long as 10 seconds.

Quoted 1 line

Is the accounting information in the status file separate for every user?

Yes.

Quoted 1 line

Which information can I get from the status file?

For each client:

Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since

For each internal routing table entry:

Virtual Address,Common Name,Real Address,Last Reference

Quoted 15 lines

--------------------------------------------------------------
End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Quoted 6 lines

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Yes, but sometimes there is a delay on UDP disconnects, since UDP is connectionless, so the call to PLUGIN_CLIENT_DISCONNECT might occur more than 1 minute after the actual disconnection. Also, with UDP, if a client disconnects and immediately reconnects using the same port number (if nobind isn't used on the client), the server will see both the original connection and the reconnect as being part of the same connection, so there won't be a call to PLUGIN_CLIENT_DISCONNECT then PLUGIN_CLIENT_CONNECT.

James

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r

#15 lore raw

Am Dienstag, den 17.05.2005, 15:20 +0400 schrieb Ralf Lübben:

Quoted 4 lines

I want to send following attribute:
Username
Password
NAS-Port = number of the tun interface

This is bad, since you must send a unique identifier to the Radius Server for every connected client if I understand this correctly.

The Radius servers decides based on a unique NAS-IP-Address:NAS-Port pair which IP-Addresse should be handed out to the client and which is in use.

Example:

NAS:XXX.XXX.XXX.40 port:0x0 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1 NAS:XXX.XXX.XXX.40 port:0x1 - ipaddr:YYY.YYY.75.YYY active:1 cli:0 num:1 [...]
NAS:XXX.XXX.XXX.40 port:0x10 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x11 - ipaddr:YYY.YYY.78.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x12 - ipaddr:YYY.YYY.72.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x13 - ipaddr:YYY.YYY.73.YYY active:1 cli:0 num:1
[...]
NAS:XXX.XXX.XXX.40 port:0x100 - ipaddr:YYY.YYY.78.YYY active:0 cli:0 num:0
NAS:XXX.XXX.XXX.40 port:0x103 - ipaddr:YYY.YYY.77.YYY active:0 cli:0 num:0

Since the tun interface is the same for every connected client connected to the same openvpn process, this will not work. One might correct me, if I am wrong on this.

So at the moment one has to generate a unique client id (NAS-Port) for every connected user. This should be done in a way that the first client gets the id (NAS-Port) 0 assigned. The next one the id 1 and so on. On disconnect the id should be reused.

For example:

client 1 connects, gets id 0
client 2 connects, gets id 1
client 3 connects, gets id 2
client 4 connects, gets id 3
client 2 disconnects, releases id 1
client 3 disconnects, releases id 2
client 5 connects, gets id 1
client 6 connects, gets id 2
[...]

I wondered whether it is possible to have a seperate tunx interface for each connected client. That would solve the problem and mimic the behaviour of ppp Connections, where you have a seperated ppp Interface for each connected client.
Is this easy possible or would that mean to rewrite most parts of OpenVPN?

Signature · 1 line
Torge Szczepanek <[email protected]...>
#32 lore raw
In reply to Ralf Lübben
Quoted 15 lines · On Tue, 17 May 2005, Ralf [UTF-8] Lübben wrote:

Hello,

I finished a C++class for the radius protocol. So I can send, receive and analyze authentication and accounting radius packets.

Now I will start to create the openvpn-plugin.

I have there still some quesitions:

When are called the funktions:
openvpn-plugin_open_v1
openvpn-plugin_func_v1
openvpn-plugin_close_v1

Quoted 4 lines

Is this right?
- openvpn-plugin_open_v1: At the start of openvpn.
- openvpn-plugin_func_v1: When the event happens.
- openvpn-plugin_close_v1: When openvpn is closed.

Yes. There's also an abort function that will be added
in 2.0.1 (see CVS or http://openvpn.net/beta/ ). The abort function gets called if there's a fatal error, so you should do a minimum cleaup such as sending a message to the worker process to close.

Quoted 3 lines

To communicate between the functions I can create
a user-defined struct, which can be shared between the functions over the openvpn_plugin_handle_t. Is that also right?

Yes.

Quoted 27 lines

I want divide the hole plugin in two parts:

1. Authorisation and Authentification
This will work like the auth-pam-plugin (split privilege execution model) only with radius support. The plugin-process holds root rights, so routes from the radius server can be set.

I want to send following attribute:
Username
Password
NAS-Port = number of the tun interface
NAS-IP-Address = ip address of the openvpn server
NAS-Identifier = user defined string

I want to analyze following attributes of the radius response:
Framed-Route = set to the server routing table and
write to the client file in client-config-dir with the iroute directive
Framed-IP-Address = write to the client file in the client-config-dir
with the (ifconfig Framed-IP IP2) directive, the other point (IP2)
must be create maybe by (IP2+1).
Acct-Interim-Interval = the accounting interval

(Maybe later a vendor specific attributs for routes which can be pushed to the client=

Quoted 6 lines

The Framed-Route and the Framed-IP-Address will be written to a file with the name of the enviroment variable envp[common-name]. At the end of a connection the routes should be deleted.

If a client disconnect, the iroutes in the OpenVpn-process are deleted automatically?

Yes.

Quoted 12 lines

2. Accounting
Here I'm not sure, want is the best way to do it, maybe somebody have some ideas.
One idea is to create for every openvpn-client who connects to the openvpn-server a own process with fork(). So every process gets his own Acct-Interim-Interval and can send the accounting data to the radius server. The data is read from the status file. This file must be accessible by the user (nobody) of the openvpn process.
If there are a lot of users, there are a lot of processes and every process reads the status file.

Quoted 5 lines

The other idea is to create only one process which handles all accounting, this process will work like the auth-pam-plugin (split privilege execution model). This process must schedule the differnt Acct-Interim-Intervals of the clients. The data is read from
the status file.

I would tend towards the latter (one process for all accounting). This will be more scalable.

Quoted 11 lines

Accounting Attributes:
Acct-Status-Type:
start - at the beginning of the connection update - during the connection
stop - at the end
NAS-Session-ID: unique for a connection
NAS-Identidier: user-defined value
Acct-Input-Octets: read from the status file
Acct-Output-Octets: read from the status file
Acct-Session-Time: intenal counter or read from the status file

Quoted 4 lines

The accounting stop ticket can only be send by the disconnect plugin. Can I share informations between plugins? So the disconnect plugin can send a disconnect signal to the accounting process, maybe over a socket? So the accounting for this users stopps and the ticket is generated.

Yes, all plugins are called via the openvpn_plugin_func_v1 function with the type parameter set to the actual plugin type such as OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY or OPENVPN_PLUGIN_CLIENT_CONNECT.

James

Quoted 195 lines
Quoted 176 lines
Quoted 15 lines

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-----------------------------------------------------------------------
Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

Quoted 8 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This
attribut can occur several times in the "access-accept-ticket".

You might need a split privilege model here, because adding routes requires root privileges, and for security reasons, we don't want to run the main OpenVPN process as root. The OpenVPN plugin model supports split privileges, i.e. where the plugin process holds onto root while the main OpenVPN process drops privileges (see auth-pam or down-root for examples of this), so you'd probably need to have the plugin fork a process to handle route additions.

Quoted 5 lines

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.

OpenVPN doesn't support this right now.

Quoted 1 line

- Idle-Timeout: The connection is disconnected, if there is no traffic

This is tricky, because how do you define traffic?

Quoted 3 lines

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

Good idea.

Quoted 12 lines

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval". This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Quoted 6 lines

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY (called first) to authorize username/password and OPENVPN_PLUGIN_CLIENT_CONNECT (called next) to push IP address and routes to client.

Quoted 2 lines

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

With 2.0.x, OpenVPN is running in a single thread, so plugin callbacks will stall the whole process.

For 2.1, there will be multithread support (two threads actually), so calls to plugins will occur from a different thread than the main packet forwarding thread. There will only be a single thread for calling plugins, so you won't need to make the plugin callbacks themselves reentrant.

Quoted 11 lines

---------------------------------------------------------------
During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

This would work, but it might be cleaner for OpenVPN 2.1 to add a new callback for passing accounting data to the plugin.

The problem with polling the status file is that there's no guarantee of change atomicity, i.e. an entry could be added and then deleted from the file between pollings.

Quoted 17 lines

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Quoted 2 lines

Questions:
Is it possible to generate the status file every second?

Yes, however if the OpenVPN event loop is not actively forwarding packets, the status file update interval could be as long as 10 seconds.

Quoted 1 line

Is the accounting information in the status file separate for every user?

Yes.

Quoted 1 line

Which information can I get from the status file?

For each client:

Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since

For each internal routing table entry:

Virtual Address,Common Name,Real Address,Last Reference

Quoted 15 lines

--------------------------------------------------------------
End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Quoted 6 lines

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Yes, but sometimes there is a delay on UDP disconnects, since UDP is connectionless, so the call to PLUGIN_CLIENT_DISCONNECT might occur more than 1 minute after the actual disconnection. Also, with UDP, if a client disconnects and immediately reconnects using the same port number (if nobind isn't used on the client), the server will see both the original connection and the reconnect as being part of the same connection, so there won't be a call to PLUGIN_CLIENT_DISCONNECT then PLUGIN_CLIENT_CONNECT.

James

Quoted 5 lines

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#16 lore raw
In reply to Torge Szczepanek
Quoted 55 lines · Torge Szczepanek

Am Dienstag, den 17.05.2005, 15:20 +0400 schrieb Ralf Lübben:

Quoted 4 lines

I want to send following attribute:
Username
Password
NAS-Port = number of the tun interface

This is bad, since you must send a unique identifier to the Radius Server for every connected client if I understand this correctly.

The Radius servers decides based on a unique NAS-IP-Address:NAS-Port pair which IP-Addresse should be handed out to the client and which is in use.

Example:

NAS:XXX.XXX.XXX.40 port:0x0 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1 NAS:XXX.XXX.XXX.40 port:0x1 - ipaddr:YYY.YYY.75.YYY active:1 cli:0 num:1 [...]
NAS:XXX.XXX.XXX.40 port:0x10 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x11 - ipaddr:YYY.YYY.78.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x12 - ipaddr:YYY.YYY.72.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x13 - ipaddr:YYY.YYY.73.YYY active:1 cli:0 num:1
[...]
NAS:XXX.XXX.XXX.40 port:0x100 - ipaddr:YYY.YYY.78.YYY active:0 cli:0 num:0
NAS:XXX.XXX.XXX.40 port:0x103 - ipaddr:YYY.YYY.77.YYY active:0 cli:0 num:0

Since the tun interface is the same for every connected client connected to the same openvpn process, this will not work. One might correct me, if I am wrong on this.

So at the moment one has to generate a unique client id (NAS-Port) for every connected user. This should be done in a way that the first client gets the id (NAS-Port) 0 assigned. The next one the id 1 and so on. On disconnect the id should be reused.

For example:

client 1 connects, gets id 0
client 2 connects, gets id 1
client 3 connects, gets id 2
client 4 connects, gets id 3
client 2 disconnects, releases id 1
client 3 disconnects, releases id 2
client 5 connects, gets id 1
client 6 connects, gets id 2
[...]

Quoted 6 lines

I wondered whether it is possible to have a seperate tunx interface for each connected client. That would solve the problem and mimic the behaviour of ppp Connections, where you have a seperated ppp Interface for each connected client.
Is this easy possible or would that mean to rewrite most parts of OpenVPN?

It's more like the opposite: 1.x supported a specific tunx interface and port for each client. 2.0 was rewritten to allow all clients to share a single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

James

#17 lore raw

Am Dienstag, den 17.05.2005, 07:18 -0600 schrieb James Yonan:

Quoted 4 lines

It's more like the opposite: 1.x supported a specific tunx interface and port for each client. 2.0 was rewritten to allow all clients to share a single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

I know this. I am using OpenVPN quite some time now. (And I am quite happy with it! ;-))

You are right. Using just one Port (and one OpenVPN process) for all clients has many advantages over the 1.x behaviour.

The only disadvantage is that one cannot disentangle different users by the device (only useful for tun (aka ptp devices)). The major advantage of this approach is that one can apply queuing disciplines for a user to a network device rather than to use tun0 and specify the users IP address. The queing discipline automatically gets removed, when the user disconnects and the device goes down.
Another advantage would be that one can use the device number in Radius Authentication for having a unique NAS-Port.

Is there an easy way to have a single OpenVPN process, running on just one port for multiple clients and assign each client a seperate tun-Device? Or would that patch be very long?

#33 lore raw
In reply to Ralf Lübben
Quoted 29 lines

2. Accounting
Here I'm not sure, want is the best way to do it, maybe somebody have some ideas.
One idea is to create for every openvpn-client who connects to the openvpn-server a own process with fork(). So every process gets his own Acct-Interim-Interval and can send the accounting data to the radius server. The data is read from the status file. This file must be accessible by the user (nobody) of the openvpn process.
If there are a lot of users, there are a lot of processes and every process reads the status file.

The other idea is to create only one process which handles all accounting, this process will work like the auth-pam-plugin (split privilege execution model). This process must schedule the differnt Acct-Interim-Intervals of the clients. The data is read from
the status file.

Accounting Attributes:
Acct-Status-Type:
start - at the beginning of the connection update - during the connection
stop - at the end
NAS-Session-ID: unique for a connection
NAS-Identidier: user-defined value
Acct-Input-Octets: read from the status file
Acct-Output-Octets: read from the status file
Acct-Session-Time: intenal counter or read from the status file

Quoted 4 lines

The accounting stop ticket can only be send by the disconnect plugin. Can I share informations between plugins? So the disconnect plugin can send a disconnect signal to the accounting process, maybe over a socket? So the accounting for this users stopps and the ticket is generated.

Regarding accounting, I am planning to add another plugin call type to pass accounting data to the plugin so that it doesn't have to read the status file to get the same info.

While the OPENVPN_PLUGIN_CLIENT_CONNECT and OPENVPN_PLUGIN_CLIENT_DISCONNECT plugin call types can be used to bracket a connection, and the latter passes final accounting data for the connection, I would add a new call type such as OPENVPN_PLUGIN_STATS which would be called once per second for any client with send/receive activity. The environmental variables common_name, bytes_sent (cumulative), and bytes_received (cumulative) would be passed to it.

James

Quoted 201 lines

support

Quoted 177 lines · James Yonan
Quoted 14 lines · On Tue, 3 May 2005, Ralf [iso-8859-1] Lübben wrote:

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-----------------------------------------------------------------------
Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

Quoted 8 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This
attribut can occur several times in the "access-accept-ticket".

You might need a split privilege model here, because adding routes requires root privileges, and for security reasons, we don't want to run the main OpenVPN process as root. The OpenVPN plugin model supports split privileges, i.e. where the plugin process holds onto root while the main OpenVPN process drops privileges (see auth-pam or down-root for examples of this), so you'd probably need to have the plugin fork a process to handle route additions.

Quoted 5 lines

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.

OpenVPN doesn't support this right now.

Quoted 1 line

- Idle-Timeout: The connection is disconnected, if there is no traffic

This is tricky, because how do you define traffic?

Quoted 3 lines

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

Good idea.

Quoted 12 lines

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval". This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Quoted 6 lines

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY (called first) to authorize username/password and OPENVPN_PLUGIN_CLIENT_CONNECT (called next) to push IP address and routes to client.

Quoted 2 lines

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

With 2.0.x, OpenVPN is running in a single thread, so plugin callbacks will stall the whole process.

For 2.1, there will be multithread support (two threads actually), so calls to plugins will occur from a different thread than the main packet forwarding thread. There will only be a single thread for calling plugins, so you won't need to make the plugin callbacks themselves reentrant.

Quoted 11 lines

---------------------------------------------------------------
During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

This would work, but it might be cleaner for OpenVPN 2.1 to add a new callback for passing accounting data to the plugin.

The problem with polling the status file is that there's no guarantee of change atomicity, i.e. an entry could be added and then deleted from the file between pollings.

Quoted 17 lines

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Quoted 2 lines

Questions:
Is it possible to generate the status file every second?

Yes, however if the OpenVPN event loop is not actively forwarding packets, the status file update interval could be as long as 10 seconds.

Quoted 1 line

Is the accounting information in the status file separate for every user?

Yes.

Quoted 1 line

Which information can I get from the status file?

For each client:

Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since

For each internal routing table entry:

Virtual Address,Common Name,Real Address,Last Reference

Quoted 15 lines

--------------------------------------------------------------
End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Quoted 6 lines

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Yes, but sometimes there is a delay on UDP disconnects, since UDP is connectionless, so the call to PLUGIN_CLIENT_DISCONNECT might occur more than 1 minute after the actual disconnection. Also, with UDP, if a client disconnects and immediately reconnects using the same port number (if nobind isn't used on the client), the server will see both the original connection and the reconnect as being part of the same connection, so there won't be a call to PLUGIN_CLIENT_DISCONNECT then PLUGIN_CLIENT_CONNECT.

James

Quoted 5 lines

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#18 lore raw
In reply to Torge Szczepanek
Quoted 22 lines · Torge Szczepanek

Am Dienstag, den 17.05.2005, 07:18 -0600 schrieb James Yonan:

Quoted 4 lines

It's more like the opposite: 1.x supported a specific tunx interface and port for each client. 2.0 was rewritten to allow all clients to share a single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

I know this. I am using OpenVPN quite some time now. (And I am quite happy with it! ;-))

You are right. Using just one Port (and one OpenVPN process) for all clients has many advantages over the 1.x behaviour.

The only disadvantage is that one cannot disentangle different users by the device (only useful for tun (aka ptp devices)). The major advantage of this approach is that one can apply queuing disciplines for a user to a network device rather than to use tun0 and specify the users IP address. The queing discipline automatically gets removed, when the user disconnects and the device goes down.
Another advantage would be that one can use the device number in Radius Authentication for having a unique NAS-Port.

Quoted 3 lines

Is there an easy way to have a single OpenVPN process, running on just one port for multiple clients and assign each client a seperate tun-Device? Or would that patch be very long?

I think the patch could be done, but it would have some disadvantages such as (a) you would need to run OpenVPN as root (without dropping privileges) because the daemon would need to dynamically open and close tun/tap devices, (b) you have all the scalability problems of dealing with a large number of network interfaces -- for example, on Windows, it's not even practical to handle more than a relatively small number of TAP-Win32 adapters, and they can't easily be created and destroyed programmatically.

James

#34 lore raw
In reply to James Yonan

Hello.

Thank you for all the ideas.

I think I will do the radius plugin in the following way:

1. Authentication:
split privilege execution model
plugin: OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY

- Attributes ACCECP-REQUEST:
- Username
- Password
- NAS-Port = unique for each user, increment if a user connects, decrement if a user disconnects
- NAS-IP-Address = ip address of the openvpn server
- NAS-Identifier = user defined string
- Service Type = "Framed" (for framed ip address assignment)

So I will manage the number of the NAS-Port, I think this is the easiest way.
Or are there great advantages if every user gets his own tun interface?
To Torge Szczepanek: Which radius server do you use?
I use freeradius and I think I can only set
a static IP addres as "Framed IP Address".
I don't know how dynamic ip assigment works
on a radius server. But I will implement the radius attributes NAS-Port, NAS-IP-Adress, NAS_Identifier and Service-Type="Framed" in the ACCEPT-REQUEST. Are these all attributes?

- Analyzed Attributes of the ACCESS-ACCEPT (no changes):
Framed-Route = set to the server routing table and
                 write to the client file in client-config-dir with the iroute directive
Framed-IP-Address = write to the client file in the client-config-dir
                         with the (ifconfig Framed-IP IP2) directive, the other point (IP2)
                         must be create maybe by (IP2+1).
Acct-Interim-Interval = the accounting interval

(Maybe later a vendor specific attributs for routes which can be pushed to the client.)

2. Accounting:
- split privilege execution model, only one process with a scheduler for the differnt Acct-Interim-Intervals of the user.
plugin: OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY
plugin: PLUGIN_CLIENT_DISCONNECT (for stop ticket)

Attributes:
Acct-Status-Type:
         start - at the beginning of the connection update - during the connection
         stop - at the end
NAS-Session-ID: unique for a connection
NAS-Identidier: user-defined value
Acct-Input-Octets: read from the status file
Acct-Output-Octets: read from the status file
Acct-Session-Time: internal counter or read from the status file
Framed-IP-Address: if the client get one

I will do the reading of the status file in a seperate function, so it can be changed easy if the plugin OPENVPN_PLUGIN_STATS is finished.

One more question to the plugin PLUGIN_CLIENT_DISCONNECT:
Does every plugin which is called, gets the pointer to thesame struct openvpn_plugin_handle_t, so I can save here the socket to the background processes and the plugin PLUGIN_CLIENT_DISCONNECT can send data to these socket numbers?

The openvpn-plugin_abort_v1 function will I add maybe later.

Are there some more ideas or hints?

Ralf

Quoted 9 lines · James Yonan
Quoted 7 lines · On Tue, 3 May 2005, Ralf [iso-8859-1] Lübben wrote:

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-------------------------------------------------------------------------------------------------------------

Quoted 68 lines
Quoted 7 lines

Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

Quoted 8 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This
attribut can occur several times in the "access-accept-ticket".

You might need a split privilege model here, because adding routes requires root privileges, and for security reasons, we don't want to run the main OpenVPN process as root. The OpenVPN plugin model supports split privileges, i.e. where the plugin process holds onto root while the main OpenVPN process drops privileges (see auth-pam or down-root for examples of this), so you'd probably need to have the plugin fork a process to handle route additions.

Quoted 5 lines

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.

OpenVPN doesn't support this right now.

Quoted 1 line

- Idle-Timeout: The connection is disconnected, if there is no traffic

This is tricky, because how do you define traffic?

Quoted 3 lines

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

Good idea.

Quoted 12 lines

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval". This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Quoted 6 lines

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY (called first) to authorize username/password and OPENVPN_PLUGIN_CLIENT_CONNECT (called next) to push IP address and routes to client.

Quoted 2 lines

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

Quoted 10 lines

With 2.0.x, OpenVPN is running in a single thread, so plugin callbacks will stall the whole process.

For 2.1, there will be multithread support (two threads actually), so calls to plugins will occur from a different thread than the main packet forwarding thread. There will only be a single thread for calling plugins, so you won't need to make the plugin callbacks themselves reentrant.

Quoted 1 line

------------------------------------------------------------------------------------------------------------

Quoted 47 lines
Quoted 10 lines

During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

This would work, but it might be cleaner for OpenVPN 2.1 to add a new callback for passing accounting data to the plugin.

The problem with polling the status file is that there's no guarantee of change atomicity, i.e. an entry could be added and then deleted from the file between pollings.

Quoted 17 lines

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Quoted 2 lines

Questions:
Is it possible to generate the status file every second?

Yes, however if the OpenVPN event loop is not actively forwarding packets, the status file update interval could be as long as 10 seconds.

Quoted 1 line

Is the accounting information in the status file separate for every user?

Yes.

Quoted 1 line

Which information can I get from the status file?

Quoted 9 lines

For each client:

Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since

For each internal routing table entry:

Virtual Address,Common Name,Real Address,Last Reference

Quoted 1 line

------------------------------------------------------------------------------------------------------

Quoted 39 lines
Quoted 14 lines

End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Quoted 6 lines

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Yes, but sometimes there is a delay on UDP disconnects, since UDP is connectionless, so the call to PLUGIN_CLIENT_DISCONNECT might occur more than 1 minute after the actual disconnection. Also, with UDP, if a client disconnects and immediately reconnects using the same port number (if nobind isn't used on the client), the server will see both the original connection and the reconnect as being part of the same connection, so there won't be a call to PLUGIN_CLIENT_DISCONNECT then PLUGIN_CLIENT_CONNECT.

James

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r

#35 lore raw
Quoted 6 lines

One more question to the plugin PLUGIN_CLIENT_DISCONNECT:
Does every plugin which is called, gets the pointer to thesame struct openvpn_plugin_handle_t, so I can save here the socket to the background processes and the plugin PLUGIN_CLIENT_DISCONNECT can send data to these socket numbers?

Yes -- each plugin (as defined by a specific "plugin" directive in the OpenVPN config file) will have a single openvpn_plugin_handle_t memory region which will be shared across all of the different PLUGIN_x plugin types.

James

Quoted 204 lines
Quoted 9 lines · James Yonan
Quoted 7 lines · On Tue, 3 May 2005, Ralf [iso-8859-1] Lübben wrote:

Hello,

I tried to create a concept for the RADIUS-Plugin.
Maybe someone have some additional ideas or can answer me some questions I wrote down in the following text.

-------------------------------------------------------------------------------------------------------------

Quoted 68 lines
Quoted 7 lines

Start of the connection:

The plugin sends a "access-request-radius-ticket" with the username and a hash(MD5-hash over the password and the shared-secret) to the radius server. If the server sends a "access-reject-ticket" or "access-challenge-ticket" the authorization fails.

Quoted 8 lines

If the server sends a "access-accept-ticket" the authorization is ok, in the ticket can be some attributes:

- Framed-IP-Address: The IP-address which is pushed to the client.

- Framed-Route: These routes have to pushed to the servers routing table. This
attribut can occur several times in the "access-accept-ticket".

You might need a split privilege model here, because adding routes requires root privileges, and for security reasons, we don't want to run the main OpenVPN process as root. The OpenVPN plugin model supports split privileges, i.e. where the plugin process holds onto root while the main OpenVPN process drops privileges (see auth-pam or down-root for examples of this), so you'd probably need to have the plugin fork a process to handle route additions.

Quoted 5 lines

- Acct-Interim-Interval: The interval in which the accounting data is sent to the radius server.

Maybe these attributes are not important :
- Session-Timeout: The maximum time for a connection.

OpenVPN doesn't support this right now.

Quoted 1 line

- Idle-Timeout: The connection is disconnected, if there is no traffic

This is tricky, because how do you define traffic?

Quoted 3 lines

Maybe it is possible to create a vendor specific attribut for routes which are pushed to the client. There is no attribut for that in the radius protocol.

Good idea.

Quoted 12 lines

After the authorization is done:
The plugin has to start another process/thread for the accounting data with the parameter value of the attribut "Acct-Interim-Interval". This process has to sent an "accounting-request-ticket" to the radius server with the attribut "acct-status-type"=1 (start). (There must be included some more attributes for the radius server (NAS-IP-address (=openvpn-ip-address) or NAS-identifier, real ip address of the user as framed-ip-address-attribut, NAS-Port or NAS-port-type)
The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Quoted 6 lines

The plugin must return 0 if everything is ok, otherwise 1.

Questions:

Which is the best plugin to use? I need the username and the password before the ip address and the routes are sent to the client?

Use OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY (called first) to authorize username/password and OPENVPN_PLUGIN_CLIENT_CONNECT (called next) to push IP address and routes to client.

Quoted 2 lines

Do the openvpn process waits until the plugin is finished? So I can write the conf-files without getting a IO-error.

Quoted 10 lines

With 2.0.x, OpenVPN is running in a single thread, so plugin callbacks will stall the whole process.

For 2.1, there will be multithread support (two threads actually), so calls to plugins will occur from a different thread than the main packet forwarding thread. There will only be a single thread for calling plugins, so you won't need to make the plugin callbacks themselves reentrant.

Quoted 1 line

------------------------------------------------------------------------------------------------------------

Quoted 47 lines
Quoted 10 lines

During the connection:

The separate process/thread which is started at the beginning of the connection sends
with the interval time of the attribut "Acct-Interim-Interval" accounting data to the radius server.
The process reads the information out of the status file which is generated by the openvpn process every second. The status file must be generated every second because the attribut "Acct-Interim-Interval" is in seconds and so nobody knows, when ths process reads the status file.

This would work, but it might be cleaner for OpenVPN 2.1 to add a new callback for passing accounting data to the plugin.

The problem with polling the status file is that there's no guarantee of change atomicity, i.e. an entry could be added and then deleted from the file between pollings.

Quoted 17 lines

The attribut "acct-status-type" must be set to 3 (interim-Update).

The process has to wait for a "accounting-response-ticket" from the server, if he gets no response he has to send the ticket again (interval=?).

Attributes in the accounting-request-ticket:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time

Quoted 2 lines

Questions:
Is it possible to generate the status file every second?

Yes, however if the OpenVPN event loop is not actively forwarding packets, the status file update interval could be as long as 10 seconds.

Quoted 1 line

Is the accounting information in the status file separate for every user?

Yes.

Quoted 1 line

Which information can I get from the status file?

Quoted 9 lines

For each client:

Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since

For each internal routing table entry:

Virtual Address,Common Name,Real Address,Last Reference

Quoted 1 line

------------------------------------------------------------------------------------------------------

Quoted 34 lines
Quoted 14 lines

End of the connection:
At the end a "accounting-request-ticket" with the "acct-status-type"=2 (stop) must be sent to the radius server.
With the following attributes:
- NAS ip address and NAS identifier
- Framed ip address (=real ip address of the client)
- NAS-port or NAS-port-type
- Acct-Input-Octets
- Acct-Output-Octets
- Acct-Input-Packets
- Acct-Output-Packets
- Acct-Session-Time
(- Acct-Terminate-Cause)

Quoted 6 lines

Also the accouting process must be killed.

I think the "PLUGIN_CLIENT_DISCONNECT"-type will be fit for this.

Questions:
Is the "PLUGIN_CLIENT_DISCONNECT"-type called at every disconnect?

Yes, but sometimes there is a delay on UDP disconnects, since UDP is connectionless, so the call to PLUGIN_CLIENT_DISCONNECT might occur more than 1 minute after the actual disconnection. Also, with UDP, if a client disconnects and immediately reconnects using the same port number (if nobind isn't used on the client), the server will see both the original connection and the reconnect as being part of the same connection, so there won't be a call to PLUGIN_CLIENT_DISCONNECT then PLUGIN_CLIENT_CONNECT.

James

Quoted 5 lines

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#36 lore raw
In reply to Ralf Lübben

Am Dienstag, den 17.05.2005, 23:39 +0400 schrieb Ralf Lübben:

Quoted 2 lines

Or are there great advantages if every user gets his own tun interface?

No. This is not really necessary.

Quoted 2 lines

To Torge Szczepanek: Which radius server do you use?
I use freeradius and I think I can only set

I am also using FreeRadius.

Quoted 1 line

a static IP addres as "Framed IP Address".

Static IP-Addresses don't need the NAS-Port Parameter to be set.

Quoted 3 lines

I don't know how dynamic ip assigment works
on a radius server. But I will implement the radius attributes NAS-Port, NAS-IP-Adress, NAS_Identifier

Dynamic IP Pools are implemented using the ippool directive in the radiusd.conf file (in FreeRadius).

Example from my config:

ippool mainpool {
name = mainpool
# range-start,range-stop: The start and end ip # addresses for the ip pool range-start = x.y.72.10
range-stop = x.y.79.255

# netmask: The network mask used for the ip's netmask = 255.255.255.255

# cache-size: The gdbm cache size for the db # files. Should be equal to the number of ip's # available in the ip pool cache-size = 2048

# session-db: The main db file used to allocate ip's to
clients
session-db = ${raddbdir}/db.ippool

# ip-index: Helper db index file used in multilink ip-index = ${raddbdir}/db.ipindex

# override: Will this ippool override a
Framed-IP-Address already set
override = no
}

In post-auth you then specify mainpool, to let the client receive a IP through radius.:

post-auth {
# Get an address from the IP Pool.
mainpool
[...]

In the accounting section you can (but must not) define an entry, where the IP is returned to the pool, when the server is seeing a stop record:

accounting {
[...]
# Return an address to the IP Pool when we see a stop record. mainpool
}

In the Users File (or somewhere else) you have to specify a Pool-Name attribute:

DEFAULT Pool-Name := mainpool

I can test the dynamic IP stuff, when you have created the Radius patch

Quoted 2 lines

and Service-Type="Framed" in the ACCEPT-REQUEST. Are these all attributes?

I think that these are all necessary attributes. If I do a tcpdump on my PPTP Server setup I see an additional Attribute, which is Framed_proto{PPP}. But for OpenVPN this is obviously not correct.

As one can see in
http://www.freeradius.org/rfc/rfc2865.html#Framed-Protocol there is no corresponding Framed-Protocol available.

Signature · 1 line
Torge Szczepanek <[email protected]...>
#19 lore raw
In reply to James Yonan

Hello,

the authentication is already working. The Framed IP Address and the Framed Routes can be set by the radius server about the auth-user-pass-verif-plugin. And every user gets a unique NAS-Port. The easiest way to do the accounting process is to start it in the auth-user-pass-verif-plugin and to add the user for accounting in the auth-user-pass-verif-plugin-function, maybe the better place is the client-connect-plugin.
Is there a differnce if a add a user to the accounting process in the auth-user-pass-verif-plugin after the authentication was successful or if I add the user at the client-connect--plugin.
Can there happen anything between the successful authentication and the client connect plugin is called?

For the time the user is authenticated the whole OpenVpn process waits on the authentication and no traffic can pass through the VPN? Is that right? Maybe the auhtentication needs some seconds. So it will be very important that authentication is timeout in a short time.

Grettings
Ralf

Quoted 48 lines · James Yonan
Quoted 24 lines · Torge Szczepanek

Am Dienstag, den 17.05.2005, 07:18 -0600 schrieb James Yonan:

Quoted 6 lines

It's more like the opposite: 1.x supported a specific tunx interface and
port for each client. 2.0 was rewritten to allow all clients to share a
single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

I know this. I am using OpenVPN quite some time now. (And I am quite happy with it! ;-))

You are right. Using just one Port (and one OpenVPN process) for all clients has many advantages over the 1.x behaviour.

The only disadvantage is that one cannot disentangle different users by the device (only useful for tun (aka ptp devices)). The major advantage of this approach is that one can apply queuing disciplines for a user to a network device rather than to use tun0 and specify the users IP address. The queing discipline automatically gets removed, when the user disconnects and the device goes down.
Another advantage would be that one can use the device number in Radius Authentication for having a unique NAS-Port.

Quoted 3 lines

Is there an easy way to have a single OpenVPN process, running on just one port for multiple clients and assign each client a seperate tun-Device? Or would that patch be very long?

I think the patch could be done, but it would have some disadvantages such as (a) you would need to run OpenVPN as root (without dropping privileges) because the daemon would need to dynamically open and close tun/tap devices, (b) you have all the scalability problems of dealing with a large number of network interfaces -- for example, on Windows, it's not even practical to handle more than a relatively small number of TAP-Win32 adapters, and they can't easily be created and destroyed programmatically.

James

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click

#20 lore raw
In reply to James Yonan

Hello,

I have a big problem with my programm.
I developed it with a test main function with the openvpn_plugin_open_v1, openvpn_plugin_func_v1 and openvpn_plugin_close_v1 function and everything works fine.
I used some c++-libraries and my whole radius stuff is in a c++-class. When I compile my programm as a shared library with the g++ and use it with OpenVpn I get the following error:

Fri May 20 17:34:32 2005 us=538779 PLUGIN: could not find symbol 'openvpn_plugin_open_v1' in plugin shared
object /root/test/auth-pam.so: /usr/sbin/openvpn: undefined symbol:
openvpn_plugin_open_v1

I think the problem is that I use c++, if I compile with the gcc the openvpn_plugin_open_v1 is found and the c++-objects are not fornd.

Is it possible to use the c++-classes and my radius classes with shared libraries in OpenVpn?
At the moment I have no idea to solve this.

Greetings
Ralf Lübben

Quoted 48 lines · James Yonan
Quoted 24 lines · Torge Szczepanek

Am Dienstag, den 17.05.2005, 07:18 -0600 schrieb James Yonan:

Quoted 6 lines

It's more like the opposite: 1.x supported a specific tunx interface and
port for each client. 2.0 was rewritten to allow all clients to share a
single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

I know this. I am using OpenVPN quite some time now. (And I am quite happy with it! ;-))

You are right. Using just one Port (and one OpenVPN process) for all clients has many advantages over the 1.x behaviour.

The only disadvantage is that one cannot disentangle different users by the device (only useful for tun (aka ptp devices)). The major advantage of this approach is that one can apply queuing disciplines for a user to a network device rather than to use tun0 and specify the users IP address. The queing discipline automatically gets removed, when the user disconnects and the device goes down.
Another advantage would be that one can use the device number in Radius Authentication for having a unique NAS-Port.

Quoted 3 lines

Is there an easy way to have a single OpenVPN process, running on just one port for multiple clients and assign each client a seperate tun-Device? Or would that patch be very long?

I think the patch could be done, but it would have some disadvantages such as (a) you would need to run OpenVPN as root (without dropping privileges) because the daemon would need to dynamically open and close tun/tap devices, (b) you have all the scalability problems of dealing with a large number of network interfaces -- for example, on Windows, it's not even practical to handle more than a relatively small number of TAP-Win32 adapters, and they can't easily be created and destroyed programmatically.

James

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click

#21 lore raw
Quoted 15 lines · On Fri, 20 May 2005, Ralf [UTF-8] Lübben wrote:

Hello,

I have a big problem with my programm.
I developed it with a test main function with the openvpn_plugin_open_v1, openvpn_plugin_func_v1 and openvpn_plugin_close_v1 function and everything works fine.
I used some c++-libraries and my whole radius stuff is in a c++-class. When I compile my programm as a shared library with the g++ and use it with OpenVpn I get the following error:

Fri May 20 17:34:32 2005 us=538779 PLUGIN: could not find symbol 'openvpn_plugin_open_v1' in plugin shared
object /root/test/auth-pam.so: /usr/sbin/openvpn: undefined symbol:
openvpn_plugin_open_v1

Quoted 6 lines

I think the problem is that I use c++, if I compile with the gcc the openvpn_plugin_open_v1 is found and the c++-objects are not fornd.

Is it possible to use the c++-classes and my radius classes with shared libraries in OpenVpn?
At the moment I have no idea to solve this.

You can declare C function prototypes in C++ code with

	extern "C" {
	  include "openvpn-plugin.h"
	}

to maintain compatibility between the C and C++ namespaces.

James

#25 lore raw
In reply to Torge Szczepanek

Hello,

at the momemt the radius plugin is working.
The plugin model is very good. It was possible to implement the plugin without any problems.

I have still one question about the NAS-Port attribute. At the moment the port number is increment for every user, but never decremt. Will this be a problem with freeradius? Must the number be in a special range, maybe for assignment?

I have still another programming question. In the plugin example for pam, all functions are static functions. Which advantages has the static function opposite to a "normal" function?

Thank you.

Ralf Lübben

#27 lore raw
In reply to a message not in the archive

Hello,

Now, the accounting informations are read from the status file, which is generated with the interval 1s. The whole accounting stuff is done by a forked process. So if there are now other causes, I do not need the plugin.

Am Dienstag, 31. Mai 2005 01:32 schrieben Sie:

Quoted 23 lines
Quoted 3 lines

at the momemt the radius plugin is working.
The plugin model is very good. It was possible to implement the plugin without any problems.

I know you were asking at one point for a plugin function to update byte-count accounting stats for each client. Do you still need this?

Quoted 4 lines

I have still one question about the NAS-Port attribute. At the moment the port number is increment for every user, but never decremt. Will this be a problem with freeradius? Must the number be in a special range, maybe for assignment?

Not sure about this one.

Quoted 3 lines

I have still another programming question. In the plugin example for pam, all functions are static functions. Which advantages has the static function opposite to a "normal" function?

It's not strictly necessary, but is done so that you can easily see which functions are externally called.

James

#28 lore raw
In reply to Ralf Lübben

Am Montag, den 30.05.2005, 19:49 +0000 schrieb Ralf Lübben:

Quoted 4 lines

I have still one question about the NAS-Port attribute. At the moment the port number is increment for every user, but never decremt. Will this be a problem with freeradius? Must the number be in a special range, maybe for assignment?

This will not be a problem for freeradius. But this has drawbacks. The problem is that if the VPN Server crashes or the Radius server doesn't get any stop record (remeber that radius is based on UDP), the server will *never* free the IP-addresses handed out to the client.

I you reuse the old Nas-Port Ids, which get free, when a client disconnects the server will free the ressource (the IP) and will hand out the IP to new users. Otherwise it would be blocked forever.

An example with increasing Nas-Port:

Freeradius has a pool of 6 IPs (a.b.c.10-a.b.c.16)

Client 1 connects gets Nas-Port 1 IP a.b.c.10
Client 2 connects gets Nas-Port 2 IP a.b.c.11
Client 3 connects gets Nas-Port 3 IP a.b.c.13
Client 4 connects gets Nas-Port 4 IP a.b.c.14
Client 5 connects gets Nas-Port 5 IP a.b.c.15

Now the communication between the OpenVPN server and the radius server is broken for some reason. Client 1-4 disconnect.

After that happened communication is restored. IPs a.b.c.10-a.b.c.15 are marked as used by clients.

Client 6 connects gets Nas-Port 6 IP a.b.c.16

Everything OK, but now if another clients connects:

Client 7 tries to connect and gets Nas-Port 7. On the radius server side all IPs are marked in-use.

An example without increasing Nas-Port:

Freeradius has a pool of 6 IPs (a.b.c.10-a.b.c.16)

Client 1 connects gets Nas-Port 1 IP a.b.c.10
Client 2 connects gets Nas-Port 2 IP a.b.c.11
Client 3 connects gets Nas-Port 3 IP a.b.c.13
Client 4 connects gets Nas-Port 4 IP a.b.c.14
Client 5 connects gets Nas-Port 5 IP a.b.c.15

Now the communication between the OpenVPN server and the radius server is broken for some reason. Client 1-4 disconnect.

After that happened communication is restored. IPs a.b.c.10-a.b.c.15 are marked as used by clients.

Client 6 connects gets Nas-Port *1* IP a.b.c.16

(Nas-Port 1 is again free since Client 1 disconnected)

Client 7 tries to connect and gets Nas-Port 2.

Client 7 connects gets Nas-Port 2 IP a.b.c.11

So everything is OK.

Signature · 1 line
Torge Szczepanek <[email protected]...>
#29 lore raw

Ok,

I think I understand the problem.
If a client send no stop packet the ip address will never be freed if the nas-port is never used again.
So if a other client connects with the same nas port number, of the client which has not send the stop packet, the freeradius server will free the ip address. And this ip address can be used again.
Is this right?

I think I will create an array which manages this problem. Maybe this stricture:
nas-port-number free
-----------------------------------------

	1				false
	2				true
	3				true
	4				false
	5				false
	6				false
	7				true

If a client connects the nas port number is locked , if a client disconnect the port number is freed.
A new client will always get the least number of the array.

Would this behaviour ok?

How many nas port numbers will I need?
I think 1000 will be enough or can there be more than 1000 clients at the same time?

Greetings,
Ralf Lübben

Am Dienstag, 31. Mai 2005 07:29 schrieb Torge Szczepanek:

Quoted 64 lines

Am Montag, den 30.05.2005, 19:49 +0000 schrieb Ralf Lübben:

Quoted 4 lines

I have still one question about the NAS-Port attribute. At the moment the port number is increment for every user, but never decremt. Will this be a problem with freeradius? Must the number be in a special range, maybe for assignment?

This will not be a problem for freeradius. But this has drawbacks. The problem is that if the VPN Server crashes or the Radius server doesn't get any stop record (remeber that radius is based on UDP), the server will *never* free the IP-addresses handed out to the client.

I you reuse the old Nas-Port Ids, which get free, when a client disconnects the server will free the ressource (the IP) and will hand out the IP to new users. Otherwise it would be blocked forever.

An example with increasing Nas-Port:

Freeradius has a pool of 6 IPs (a.b.c.10-a.b.c.16)

Client 1 connects gets Nas-Port 1 IP a.b.c.10
Client 2 connects gets Nas-Port 2 IP a.b.c.11
Client 3 connects gets Nas-Port 3 IP a.b.c.13
Client 4 connects gets Nas-Port 4 IP a.b.c.14
Client 5 connects gets Nas-Port 5 IP a.b.c.15

Now the communication between the OpenVPN server and the radius server is broken for some reason. Client 1-4 disconnect.

After that happened communication is restored. IPs a.b.c.10-a.b.c.15 are marked as used by clients.

Client 6 connects gets Nas-Port 6 IP a.b.c.16

Everything OK, but now if another clients connects:

Client 7 tries to connect and gets Nas-Port 7. On the radius server side all IPs are marked in-use.

An example without increasing Nas-Port:

Freeradius has a pool of 6 IPs (a.b.c.10-a.b.c.16)

Client 1 connects gets Nas-Port 1 IP a.b.c.10
Client 2 connects gets Nas-Port 2 IP a.b.c.11
Client 3 connects gets Nas-Port 3 IP a.b.c.13
Client 4 connects gets Nas-Port 4 IP a.b.c.14
Client 5 connects gets Nas-Port 5 IP a.b.c.15

Now the communication between the OpenVPN server and the radius server is broken for some reason. Client 1-4 disconnect.

After that happened communication is restored. IPs a.b.c.10-a.b.c.15 are marked as used by clients.

Client 6 connects gets Nas-Port *1* IP a.b.c.16

(Nas-Port 1 is again free since Client 1 disconnected)

Client 7 tries to connect and gets Nas-Port 2.

Client 7 connects gets Nas-Port 2 IP a.b.c.11

So everything is OK.

#30 lore raw

Am Dienstag, den 31.05.2005, 10:09 +0000 schrieb Ralf Lübben:

Quoted 5 lines

If a client connects the nas port number is locked , if a client disconnect the port number is freed.
A new client will always get the least number of the array.

Would this behaviour ok?

Yes. That would be OK.

Quoted 3 lines

How many nas port numbers will I need?
I think 1000 will be enough or can there be more than 1000 clients at the same time?

Hmm. Must there be a limit? I am asking since I had some troubles with a PPTP VPN pushing this to more than 100 or 256 users. So software hardlimits aren't really a good choice. If this isn't to much work I would suggest to put in a dynamic variable. Since you are using C++ you might just use a STL type? I don't know whether STLs are portable across platforms...

#31 lore raw

Ok,
I implemented a list. Everytime a user connects he gets the least number which is free or a new number is added to the list.

But how do you want to create the ip address pool?
Every client needs two ip addresses for one interface.
I get the framed ip address from the radius answer packet.
The first ip address is the ip address in framed ip address attribute, the second ip address is generated by incrementing the last byte of the address:

Example:
framed ip address: 10.8.0.20
second ip address: 10.8.0.21
client config file => ifconfig-push 10.8.0.20 10.8.0.21

I have no I idea what happens if an other client gets the ip pair 10.8.0.21 & 10.8.0.22.
On windows both ip address must be out of one /30-subnet.

Can you make this assignment with freeradius?
If the framed ip attribute is set in the users configuration file it will be task of the admin to set the right ip addresses.

Greetings
Ralf

Am Dienstag, 31. Mai 2005 12:24 schrieb Torge Szczepanek:

Quoted 33 lines

Am Dienstag, den 31.05.2005, 10:09 +0000 schrieb Ralf Lübben:

Quoted 5 lines

If a client connects the nas port number is locked , if a client disconnect the port number is freed.
A new client will always get the least number of the array.

Would this behaviour ok?

Yes. That would be OK.

Quoted 3 lines

How many nas port numbers will I need?
I think 1000 will be enough or can there be more than 1000 clients at the same time?

Hmm. Must there be a limit? I am asking since I had some troubles with a PPTP VPN pushing this to more than 100 or 256 users. So software hardlimits aren't really a good choice. If this isn't to much work I would suggest to put in a dynamic variable. Since you are using C++ you might just use a STL type? I don't know whether STLs are portable across platforms...

-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! directly into your own Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#23 lore raw
In reply to James Yonan

Hello,

I have again two questions about the counter for the bytes send and received:

What is the datatype of the counters?
Radius only knows 32-bit unsingned integers.

Which traffic is counted?
Is only the real payload counted without the encryption overhead? What about the keepalive packets?
I see there is always a little bit of traffic.
Is it possible to count only the real payload or must I subtract the other bytes from the counters in the plugin?

Greetings
Ralf

Quoted 77 lines · James Yonan
Quoted 55 lines · Torge Szczepanek

Am Dienstag, den 17.05.2005, 15:20 +0400 schrieb Ralf Lübben:

Quoted 4 lines

I want to send following attribute:
Username
Password
NAS-Port = number of the tun interface

This is bad, since you must send a unique identifier to the Radius Server for every connected client if I understand this correctly.

The Radius servers decides based on a unique NAS-IP-Address:NAS-Port pair which IP-Addresse should be handed out to the client and which is in use.

Example:

NAS:XXX.XXX.XXX.40 port:0x0 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1 NAS:XXX.XXX.XXX.40 port:0x1 - ipaddr:YYY.YYY.75.YYY active:1 cli:0 num:1 [...]
NAS:XXX.XXX.XXX.40 port:0x10 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x11 - ipaddr:YYY.YYY.78.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x12 - ipaddr:YYY.YYY.72.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x13 - ipaddr:YYY.YYY.73.YYY active:1 cli:0 num:1
[...]
NAS:XXX.XXX.XXX.40 port:0x100 - ipaddr:YYY.YYY.78.YYY active:0 cli:0 num:0
NAS:XXX.XXX.XXX.40 port:0x103 - ipaddr:YYY.YYY.77.YYY active:0 cli:0 num:0

Since the tun interface is the same for every connected client connected to the same openvpn process, this will not work. One might correct me, if I am wrong on this.

So at the moment one has to generate a unique client id (NAS-Port) for every connected user. This should be done in a way that the first client gets the id (NAS-Port) 0 assigned. The next one the id 1 and so on. On disconnect the id should be reused.

For example:

client 1 connects, gets id 0
client 2 connects, gets id 1
client 3 connects, gets id 2
client 4 connects, gets id 3
client 2 disconnects, releases id 1
client 3 disconnects, releases id 2
client 5 connects, gets id 1
client 6 connects, gets id 2
[...]

Quoted 6 lines

I wondered whether it is possible to have a seperate tunx interface for each connected client. That would solve the problem and mimic the behaviour of ppp Connections, where you have a seperated ppp Interface for each connected client.
Is this easy possible or would that mean to rewrite most parts of OpenVPN?

It's more like the opposite: 1.x supported a specific tunx interface and port for each client. 2.0 was rewritten to allow all clients to share a single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

James

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_idt12&alloc_id344&opclick

#24 lore raw
Quoted 7 lines · On Fri, 3 Jun 2005, Ralf [UTF-8] Lübben wrote:

Hello,

I have again two questions about the counter for the bytes send and received:

What is the datatype of the counters?
Radius only knows 32-bit unsingned integers.

Right now the counters are 32 bits, but they may be expanded to 64 bits in the future.

Quoted 6 lines

Which traffic is counted?
Is only the real payload counted without the encryption overhead? What about the keepalive packets?
I see there is always a little bit of traffic.
Is it possible to count only the real payload or must I subtract the other bytes from the counters in the plugin?

OpenVPN internally keeps track of most of these, but right now only the total number of bytes sent over the TCP or UDP socket (including encryption overhead, keepalives, etc.) is included.

James

Quoted 93 lines
Quoted 69 lines · James Yonan
Quoted 55 lines · Torge Szczepanek

Am Dienstag, den 17.05.2005, 15:20 +0400 schrieb Ralf Lübben:

Quoted 4 lines

I want to send following attribute:
Username
Password
NAS-Port = number of the tun interface

This is bad, since you must send a unique identifier to the Radius Server for every connected client if I understand this correctly.

The Radius servers decides based on a unique NAS-IP-Address:NAS-Port pair which IP-Addresse should be handed out to the client and which is in use.

Example:

NAS:XXX.XXX.XXX.40 port:0x0 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1 NAS:XXX.XXX.XXX.40 port:0x1 - ipaddr:YYY.YYY.75.YYY active:1 cli:0 num:1 [...]
NAS:XXX.XXX.XXX.40 port:0x10 - ipaddr:YYY.YYY.76.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x11 - ipaddr:YYY.YYY.78.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x12 - ipaddr:YYY.YYY.72.YYY active:1 cli:0 num:1
NAS:XXX.XXX.XXX.40 port:0x13 - ipaddr:YYY.YYY.73.YYY active:1 cli:0 num:1
[...]
NAS:XXX.XXX.XXX.40 port:0x100 - ipaddr:YYY.YYY.78.YYY active:0 cli:0 num:0
NAS:XXX.XXX.XXX.40 port:0x103 - ipaddr:YYY.YYY.77.YYY active:0 cli:0 num:0

Since the tun interface is the same for every connected client connected to the same openvpn process, this will not work. One might correct me, if I am wrong on this.

So at the moment one has to generate a unique client id (NAS-Port) for every connected user. This should be done in a way that the first client gets the id (NAS-Port) 0 assigned. The next one the id 1 and so on. On disconnect the id should be reused.

For example:

client 1 connects, gets id 0
client 2 connects, gets id 1
client 3 connects, gets id 2
client 4 connects, gets id 3
client 2 disconnects, releases id 1
client 3 disconnects, releases id 2
client 5 connects, gets id 1
client 6 connects, gets id 2
[...]

Quoted 6 lines

I wondered whether it is possible to have a seperate tunx interface for each connected client. That would solve the problem and mimic the behaviour of ppp Connections, where you have a seperated ppp Interface for each connected client.
Is this easy possible or would that mean to rewrite most parts of OpenVPN?

It's more like the opposite: 1.x supported a specific tunx interface and port for each client. 2.0 was rewritten to allow all clients to share a single tun/tap interface and TCP/UDP port. The 2.0 approach tends to be preferred because it scales better and is easier to manage.

Quoted 8 lines

James

-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be the first software developer in space? Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_idt12&alloc_id344&opclick

-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#37 lore raw
In reply to Ralf Lübben

Hello,

the radius plugin in is working.
I have still some questions about the OpenVpn behaviour.

After one hour there is a rekeying/reauthentication of the user? Is that right. The problem is that before an user can be authenticated from the plugin the user needs a disconnect from OpenVpn for this user. At the moment the reauthentenication fails and the OpenVpn disconnects the user after the keepalive interval. Ather this the user can connect again.

Have I the possibility to get the information if the authentication is a new or a reauthentication from the enviroment variable?

Maybe if I already have the user in my internal list and the user comes in with the same username, password and remote_ip he is authenticated without asking the radius server.
The other possibility is too delete the user from the list and add the user again to the list.

What are about the counters in the status file? Are they set to 0 at the rekeying/reauthentication? So I have to send the stop ticket to the radius server and I have to send again a start ticket.

What are the maximum length of strings in the enviroment that I can get from the OpenVpn process? Maybe 128 characters for the username and password.

Ralf Lübben

Quoted 35 lines · Ralf Lübben

Hello,

I am interesting in build radius support for OpenVpn. At the moment I'am thinking about what is the best way.

1. Authentification and Authroization:
I think this already works with the plugin pam_radius_auth.so, is that right?

But I am interested in more features,
like to get the ip-address and the routes from the RADIUS-Server. Can this be done with a plugin? Maybe by creating the configurationfiles at the start of the connection?
Or could this be integrated in the Source Code? I think this would be the best solution.
I hope the fea
2. Accounting:
I need to count the traffic of a VPN-connection, one the side every traffic which goes from a client to the server (tun0-interface) and one the other side every traffic which goes through the VPN, maybe from one client to another client.
So when I use the counter of the tun-interface, I lose the traffic which goes from one client to another. If I count the traffic of the eth-interface I get other traffic, which has nothing to do with the vpn.

Maybe someone has some experiences with this topic and give some hints which is the best way? To do all things in a modul or to do all changes in the source code. and where I have to look in the source code to integrate this feature.

I hope there is a gerneal interest in this feature.

For every help I am very grateful.

Ralf Lübben

#38 lore raw
Quoted 7 lines · On Fri, 24 Jun 2005, Ralf [UTF-8] Lübben wrote:

Hello,

the radius plugin in is working.
I have still some questions about the OpenVpn behaviour.

After one hour there is a rekeying/reauthentication of the user? Is that right.

Yes, this depends on the value of the --reneg-sec parameter which is usually set to 3600.

Quoted 5 lines

The problem is that before an user can be authenticated from the plugin the user needs a disconnect from OpenVpn for this user. At the moment the reauthentenication fails and the OpenVpn disconnects the user after the keepalive interval. Ather this the user can connect again.

Quoted 8 lines

Have I the possibility to get the information if the authentication is a new or a reauthentication from the enviroment variable?

Maybe if I already have the user in my internal list and the user comes in with the same username, password and remote_ip he is authenticated without asking the radius server.
The other possibility is too delete the user from the list and add the user again to the list.

One thing that I'm thinking about adding to the plugin interface is an explicit constructor and destructor callback for client instance objects, and a related client handle which would be passed to all the plugin functions.

Right now, the best way to do this is to track client-connect and client-disconnect calls.

Quoted 3 lines

What are about the counters in the status file? Are they set to 0 at the rekeying/reauthentication? So I have to send the stop ticket to the radius server and I have to send again a start ticket.

The rekeying is "under the hood" and should mostly be invisible from the perspective of a plugin. There shouldn't be any client-disconnect/client-connect cycling when this occurs.

Quoted 2 lines

What are the maximum length of strings in the enviroment that I can get from the OpenVpn process? Maybe 128 characters for the username and password.

Right now the max username and password length is defined as

#define USER_PASS_LEN 128

in misc.c (each separately can be up to this length).

However, for environmental variables in general, there is no length restriction.

James

Quoted 54 lines

Ralf Lübben

Quoted 30 lines · Ralf Lübben

Hello,

I am interesting in build radius support for OpenVpn. At the moment I'am thinking about what is the best way.

1. Authentification and Authroization:
I think this already works with the plugin pam_radius_auth.so, is that right?

But I am interested in more features,
like to get the ip-address and the routes from the RADIUS-Server. Can this be done with a plugin? Maybe by creating the configurationfiles at the start of the connection?
Or could this be integrated in the Source Code? I think this would be the best solution.
I hope the fea
2. Accounting:
I need to count the traffic of a VPN-connection, one the side every traffic which goes from a client to the server (tun0-interface) and one the other side every traffic which goes through the VPN, maybe from one client to another client.
So when I use the counter of the tun-interface, I lose the traffic which goes from one client to another. If I count the traffic of the eth-interface I get other traffic, which has nothing to do with the vpn.

Maybe someone has some experiences with this topic and give some hints which is the best way? To do all things in a modul or to do all changes in the source code. and where I have to look in the source code to integrate this feature.

Quoted 5 lines

I hope there is a gerneal interest in this feature.

For every help I am very grateful.

Ralf Lübben

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel