Multiple VPN connections on the same port
Hi,
Firstly I'd like to thank you a prompt responce to my last question - it was most helpful.
Now I am looking into the posibility of setting up a VPN server that will accept incoming VPN connections from some number of clients. (I do realize that client/server only really applies to TLS-mode, by client I really just mean the machine that will initialize the connection, the one that will be started with --remote) However I am not sure how to best implement this since I don't know the number of clients in advance, so I can't really have a port assigned to each client. Instead I would like to have all clients to connect to the server on the same port. I did not however find a way to do so with OpenVPN. When I tried to have to have two clients connect to the same server, they just kept periodically knocking each other off with error messages of the sort:
105: TLS Error: Unroutable control packet received from 192.168.xx.xx:7000 (si=3 op=P_CONTROL_SOFT_RESET_V1)
So I guess my question is, is it supposed to work? The man page says that you "should" have all the connections use a different port, which would imply that it is possible to do the opposite, but I was not able to get it to work....
If it is not possible, as far as I understand it should not be too hard to implement... We could have the server start out bound to the listening port, but not connected, and when we get an incoming connection from some ip, we fork and call connect in the child, so that in the future all packets from that ip would go to that process. Right?
Would this work? Is there a better way to accomplish this?
--
Thanks in advance,
mag
Hi Michael,
Right now OpenVPN doesn't support a forking-server model on a single port, it's strictly peer-to-peer with an OpenVPN process instantiated at both ends of the connection, and each connection on a unique port.
There has been some recent discussions about a forking-server implementation on this list -- see the "add a server feature to openvpn to share udp ports?" thread in the openvpn-devel archives.
I think the simplest way to do this would be something like:
(1) Add a --forking-server flag that causes the main OpenVPN event loop to fork a new process for each initial datagram received from a client.
(2) The newly forked server process switches to a dynamic port before responding back to the connecting client. This is quite a bit simpler and more efficient than trying to run all clients over the same UDP port.
(3) OpenVPN already has code (see the implementation of --float) that will adapt to the new port number returned by the response to initial datagram sent from server to client. I have also confirmed that this type of UDP port switch is recognized by both Linux and Cisco stateful firewalls.
There are a some complications that would need to be handled:
(1) You would need to protect against DoS attacks that flood the server with fork requests. Possibly some variation of --tls-auth that would authenticate the initial packet before the fork call.
(2) If a client connects, gets disconnected, then connects again, you would need to make sure that the old server process gets killed before a new server process is forked.
Unfortunately I'm pretty busy right now with my day job, so I may not get to this for a while. If you want to take a shot at some kind of implementation, I will do my best to answer your questions.
Best Regards,
James
----- Original Message -----
From: "Michael Grigoriev" <[email protected]...>
To: <[email protected]>
Sent: Monday, July 22, 2002 6:53 PM
Subject: [Openvpn-devel] Multiple VPN connections on the same port
Quoted 45 lines
Hi,
Firstly I'd like to thank you a prompt responce to my last question - it was most helpful.
Now I am looking into the posibility of setting up a VPN server that will accept incoming VPN connections from some number of clients. (I do realize that client/server only really applies to TLS-mode, by client I really just mean the machine that will initialize the connection, the one that will be started with --remote) However I am not sure how to best implement this since I don't know the number of clients in advance, so I can't really have a port assigned to each client. Instead I would like to have all clients to connect to the server on the same port. I did not however find a way to do so with OpenVPN. When I tried to have to have two clients connect to the same server, they just kept periodically knocking each other off with error messages of the sort:
105: TLS Error: Unroutable control packet received from 192.168.xx.xx:7000 (si=3 op=P_CONTROL_SOFT_RESET_V1)
So I guess my question is, is it supposed to work? The man page says that you "should" have all the connections use a different port, which would imply that it is possible to do the opposite, but I was not able to get it to work....
If it is not possible, as far as I understand it should not be too hard to implement... We could have the server start out bound to the listening port, but not connected, and when we get an incoming connection from some ip, we fork and call connect in the child, so that in the future all packets from that ip would go to that process. Right?Would this work? Is there a better way to accomplish this?
--
Thanks in advance,
mag-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Hello James and Michael,
I have been busy writing a forking server addon to openvpn.
In openvpn.c I have separated the processing of parameters from main() to a new function and moved main to another file to allow me to link against different main() functions.
One that implements normal peer2peer vpn and two others that produces forkin' server and client.
These use a simple UDP protocol to agree a port to use, after which server forks do some handshaking with client and then calls openvpn() funcition from openvpn.c
This way I have been able to keep those well tested procedures and protocol of openvpn untouched.
I still have some questions unsolved like DoS protection, dropping root priviledges and how to handel SIGUSR1 and SIGHUP.
I hope I can overcome these and mail you a patch.
Sampo
Quoted 103 lines
Hi Michael,
Right now OpenVPN doesn't support a forking-server model on a single port, it's strictly peer-to-peer with an OpenVPN process instantiated at both ends of the connection, and each connection on a unique port.
There has been some recent discussions about a forking-server implementation on this list -- see the "add a server feature to openvpn to share udp ports?" thread in the openvpn-devel archives.
I think the simplest way to do this would be something like:
(1) Add a --forking-server flag that causes the main OpenVPN event loop to fork a new process for each initial datagram received from a client.
(2) The newly forked server process switches to a dynamic port before responding back to the connecting client. This is quite a bit simpler and more efficient than trying to run all clients over the same UDP port.
(3) OpenVPN already has code (see the implementation of --float) that will adapt to the new port number returned by the response to initial datagram sent from server to client. I have also confirmed that this type of UDP port switch is recognized by both Linux and Cisco stateful firewalls.There are a some complications that would need to be handled:
(1) You would need to protect against DoS attacks that flood the server with fork requests. Possibly some variation of --tls-auth that would authenticate the initial packet before the fork call.
(2) If a client connects, gets disconnected, then connects again, you would need to make sure that the old server process gets killed before a new server process is forked.
Unfortunately I'm pretty busy right now with my day job, so I may not get to this for a while. If you want to take a shot at some kind of implementation, I will do my best to answer your questions.
Best Regards,
James----- Original Message -----
From: "Michael Grigoriev" <[email protected]...>
To: <[email protected]>
Sent: Monday, July 22, 2002 6:53 PM
Subject: [Openvpn-devel] Multiple VPN connections on the same portQuoted 36 lines
Hi,
Firstly I'd like to thank you a prompt responce to my last question - it was most helpful.
Now I am looking into the posibility of setting up a VPN server that will accept incoming VPN connections from some number of clients. (I do realize that client/server only really applies to TLS-mode, by client I really just mean the machine that will initialize the connection, the one that will be started with --remote) However I am not sure how to best implement this since I don't know the number of clients in advance, so I can't really have a port assigned to each client. Instead I would like to have all clients to connect to the server on the same port. I did not however find a way to do so with OpenVPN. When I tried to have to have two clients connect to the same server, they just kept periodically knocking each other off with error messages of the sort:
105: TLS Error: Unroutable control packet received from 192.168.xx.xx:7000 (si=3 op=P_CONTROL_SOFT_RESET_V1)
So I guess my question is, is it supposed to work? The man page says that you "should" have all the connections use a different port, which would imply that it is possible to do the opposite, but I was not able to get it to work....
If it is not possible, as far as I understand it should not be too hard to implement... We could have the server start out bound to the listening port, but not connected, and when we get an incoming connection from some ip, we fork and call connect in the child, so that in the future all packets from that ip would go to that process. Right?Would this work? Is there a better way to accomplish this?
--
Thanks in advance,
magQuoted 9 lines
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Hi Sampo,
Quoted 2 lines
I have been busy writing a forking server addon to openvpn.
Cool... Does each potential connecting client need a separate config file, or does the server use a common client template and then keep track of things like dynamic ports, dynamic endpoint addresses, etc?
Quoted 5 lines
In
openvpn.cI have separated the processing of parameters frommain()to a new function and moved main to another file to allow me to link against differentmain()functions.
Quoted 8 lines
One that implements normal peer2peer vpn and two others that produces forkin' server and client.
These use a simple UDP protocol to agree a port to use, after which server forks do some handshaking with client and then calls
openvpn()funcition fromopenvpn.c
Are you sure there needs to be a new protocol to do this?
Suppose the master server listens on a particular port, reads the initial datagram from a connecting client, verifies the integrity of the datagram using a --tls-auth variant, allocates a dynamic port, forks a new server process, and continues in its event loop.
When the forked process finishes up the TLS authentication, it can take the Common Name from the client certificate and use it to determine the appropriate config profile to use (containing ifconfig addresses, route statements, etc.)
Or the handshaking could be done by passing a configuration string in the TLS payload, similar to the string now built by options_string().
Quoted 7 lines
This way I have been able to keep those well tested procedures and protocol of openvpn untouched.
I still have some questions unsolved like DoS protection, dropping root priviledges and how to handel SIGUSR1 and SIGHUP.
Maybe keep track of all children, so when the master process gets a signal, it dispatches it to each child process, then to itself.
Quoted 6 lines
I hope I can overcome these and mail you a patch.
Quoted 7 lines
Sampo
Quoted 3 lines
Hi Michael,
Right now OpenVPN doesn't support a forking-server model on a single
port,
Quoted 1 line
Quoted 1 line
it's strictly peer-to-peer with an OpenVPN process instantiated at both
ends
Quoted 3 lines
Quoted 3 lines
of the connection, and each connection on a unique port.
There has been some recent discussions about a forking-server
implementation
Quoted 6 lines
Quoted 6 lines
on this list -- see the "add a server feature to openvpn to share udp ports?" thread in the openvpn-devel archives.
I think the simplest way to do this would be something like:
(1) Add a --forking-server flag that causes the main OpenVPN event loop
to
Quoted 3 lines
Quoted 3 lines
fork a new process for each initial datagram received from a client.
(2) The newly forked server process switches to a dynamic port before responding back to the connecting client. This is quite a bit simpler
and
Quoted 2 lines
Quoted 2 lines
more efficient than trying to run all clients over the same UDP port.
(3) OpenVPN already has code (see the implementation of --float) that
will
Quoted 1 line
Quoted 1 line
adapt to the new port number returned by the response to initial
datagram
Quoted 6 lines
Quoted 6 lines
sent from server to client. I have also confirmed that this type of UDP port switch is recognized by both Linux and Cisco stateful firewalls.
There are a some complications that would need to be handled:
(1) You would need to protect against DoS attacks that flood the server
with
Quoted 4 lines
Quoted 4 lines
fork requests. Possibly some variation of --tls-auth that would authenticate the initial packet before the fork call.
(2) If a client connects, gets disconnected, then connects again, you
would
Quoted 4 lines
Quoted 4 lines
need to make sure that the old server process gets killed before a new server process is forked.
Unfortunately I'm pretty busy right now with my day job, so I may not
get to
Quoted 13 lines
Quoted 13 lines
this for a while. If you want to take a shot at some kind of implementation, I will do my best to answer your questions.
Best Regards,
James----- Original Message -----
From: "Michael Grigoriev" <[email protected]...>
To: <[email protected]>
Sent: Monday, July 22, 2002 6:53 PM
Subject: [Openvpn-devel] Multiple VPN connections on the same port
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Hi,
Firstly I'd like to thank you a prompt responce to my last question - it was most helpful.
Now I am looking into the posibility of setting up a VPN server that will accept incoming VPN connections from some number of clients. (I
do
Quoted 1 line
Quoted 1 line
Quoted 1 line
realize that client/server only really applies to TLS-mode, by client
I
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
really just mean the machine that will initialize the connection, the one that will be started with --remote) However I am not sure how to best implement this since I don't know the number of clients in advance, so I can't really have a port assigned to each client.
Instead
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
I would like to have all clients to connect to the server on the same port. I did not however find a way to do so with OpenVPN. When I tried to have to have two clients connect to the same server, they just kept periodically knocking each other off with error messages of the sort:
105: TLS Error: Unroutable control packet received from 192.168.xx.xx:7000 (si=3 op=P_CONTROL_SOFT_RESET_V1)
So I guess my question is, is it supposed to work? The man page says that you "should" have all the connections use a different port, which would imply that it is possible to do the opposite, but I was not able to get it to work....
If it is not possible, as far as I understand it should not be too
hard
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
to implement... We could have the server start out bound to the listening port, but not connected, and when we get an incoming connection from some ip, we fork and call connect in the child, so
that
Quoted 1 line
Quoted 1 line
Quoted 1 line
in the future all packets from that ip would go to that process.
Right?
Quoted 31 lines
Quoted 30 lines
Quoted 9 lines
Would this work? Is there a better way to accomplish this?
--
Thanks in advance,
magQuoted 9 lines
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
hi,
Quoted 8 lines
Hi Sampo,
Quoted 2 lines
I have been busy writing a forking server addon to openvpn.
Cool... Does each potential connecting client need a separate config file, or does the server use a common client template and then keep track of things like dynamic ports, dynamic endpoint addresses, etc?
No they don't. I just use normal config files/command line and use --remote as server addres in the client.
I just got it running. Still with out dynamic ip address assigment and proper signal handling in parent process. And there ain't anykind of DoS protection yet.
Lack of dynamic addresses still limits it to a single connection but a pool of addresses should not be too hard to implement.
There are also need for a few new options like the range of ports/addresses used.
Ofcourse there should also be an ability to define addresses to each client. I haven't decided how to do that yet.
Quoted 9 lines
Quoted 9 lines
In
openvpn.cI have separated the processing of parameters frommain()to a new function and moved main to another file to allow me to link against differentmain()functions.One that implements normal peer2peer vpn and two others that produces forkin' server and client.
Quoted 6 lines
Quoted 4 lines
These use a simple UDP protocol to agree a port to use, after which server forks do some handshaking with client and then calls
openvpn()funcition fromopenvpn.cAre you sure there needs to be a new protocol to do this?
No, I am not. But found it easy to implement in this manner.
Quoted 4 lines
Suppose the master server listens on a particular port, reads the initial datagram from a connecting client, verifies the integrity of the datagram using a --tls-auth variant, allocates a dynamic port, forks a new server process, and continues in its event loop.
It really sounds reasonable. I also though of some kind of message authentication before fork. --tls-auth sounds good since it is quite light-weight.
Quoted 7 lines
When the forked process finishes up the TLS authentication, it can take the Common Name from the client certificate and use it to determine the appropriate config profile to use (containing ifconfig addresses, route statements, etc.)
Or the handshaking could be done by passing a configuration string in the TLS payload, similar to the string now built by
options_string().
At the moment I do some handshaking in dynamically allocated port before calling openvpn(). Mayby I could add the exchange of address info here, since I don't think it needs to be transferred over a secure channel.
Quoted 10 lines
Quoted 7 lines
This way I have been able to keep those well tested procedures and protocol of openvpn untouched.
I still have some questions unsolved like DoS protection, dropping root priviledges and how to handel SIGUSR1 and SIGHUP.
Maybe keep track of all children, so when the master process gets a signal, it dispatches it to each child process, then to itself.
Sounds good to me. I am going to keep track of childs anyway to maintain address/port pool.
Trying to explain things to someone,
amazingly helps to figure out those things for one self! I got a bunch of new ideas while writing this.
Got to go home now or I will sit coding here until midnight :-)
Sampo
Quoted 4 lines
Quoted 4 lines
Hi Sampo,
Quoted 2 lines
I have been busy writing a forking server addon to openvpn.
Will forking server only work for TLS mode?
Quoted 2 lines
Quoted 2 lines
Cool... Does each potential connecting client need a separate config
file,
Quoted 9 lines
Quoted 2 lines
or does the server use a common client template and then keep track of things like dynamic ports, dynamic endpoint addresses, etc?
No they don't. I just use normal config files/command line and use --remote as server addres in the client.
I just got it running. Still with out dynamic ip address assigment and proper signal handling in parent process. And there ain't anykind of DoS protection yet.
One way to do DoS protection would be to augment --tls-auth with persistent anti-replay protection by saving the Session ID (struct session_id) and reject any Session ID that was seen before.
Quoted 27 lines
Lack of dynamic addresses still limits it to a single connection but a pool of addresses should not be too hard to implement.
There are also need for a few new options like the range of ports/addresses used.
Ofcourse there should also be an ability to define addresses to each client. I haven't decided how to do that yet.
Quoted 14 lines
Quoted 13 lines
In
openvpn.cI have separated the processing of parameters frommain()to a new function and moved main to another file to allow me to link against differentmain()functions.One that implements normal peer2peer vpn and two others that produces forkin' server and client.
These use a simple UDP protocol to agree a port to use, after which server forks do some handshaking with client and then calls
openvpn()funcition fromopenvpn.c
Quoted 6 lines
Quoted 1 line
Are you sure there needs to be a new protocol to do this?
No, I am not. But found it easy to implement in this manner.
Quoted 1 line
Suppose the master server listens on a particular port, reads the
initial
Quoted 1 line
Quoted 1 line
datagram from a connecting client, verifies the integrity of the
datagram
Quoted 8 lines
Quoted 2 lines
using a --tls-auth variant, allocates a dynamic port, forks a new server process, and continues in its event loop.
It really sounds reasonable. I also though of some kind of message authentication before fork. --tls-auth sounds good since it is quite light-weight.
Quoted 1 line
When the forked process finishes up the TLS authentication, it can take
the
Quoted 5 lines
Quoted 5 lines
Common Name from the client certificate and use it to determine the appropriate config profile to use (containing ifconfig addresses, route statements, etc.)
Or the handshaking could be done by passing a configuration string in
the
Quoted 6 lines
Quoted 1 line
TLS payload, similar to the string now built by
options_string().At the moment I do some handshaking in dynamically allocated port before calling
openvpn(). Mayby I could add the exchange of address info here, since I don't think it needs to be transferred over a secure channel.
Actually the temporary keys + options_string() get passed over the secure TLS channel, so you could add further handshaking options and they would be secure.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
This way I have been able to keep those well tested procedures and protocol of openvpn untouched.
I still have some questions unsolved like DoS protection, dropping root priviledges and how to handel SIGUSR1 and SIGHUP.
It would be cool if we could get the forking server to work with dropping root privs.
One of the goals of dropping privs is that no datagram is ever read from the network with root privs.
It would be great if we could preserve this behavior.
Otherwise the split privileges model of the new openssh would be a possibility, but it's more complex.
Quoted 2 lines
Quoted 2 lines
Maybe keep track of all children, so when the master process gets a
signal,
Quoted 11 lines
Quoted 1 line
it dispatches it to each child process, then to itself.
Sounds good to me. I am going to keep track of childs anyway to maintain address/port pool.
Trying to explain things to someone,
amazingly helps to figure out those things for one self! I got a bunch of new ideas while writing this.
Quoted 7 lines
Got to go home now or I will sit coding here until midnight :-)
Sampo
James
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Hi Sampo,
Quoted 2 lines
I have been busy writing a forking server addon to openvpn.
Will forking server only work for TLS mode?
No, It works also with shared secret or without
security.
For prefork security I could use either the key used for tls-auth or preshared secret.
Any examples of how to implement tls-auth like
authentication in simples form?
Quoted 9 lines
Quoted 5 lines
--remote as server addres in the client.
I just got it running. Still with out dynamic ip address assigment and proper signal handling in parent process. And there ain't anykind of DoS protection yet.
One way to do DoS protection would be to augment --tls-auth with persistent anti-replay protection by saving the Session ID (struct
session_id) and reject any Session ID that was seen before.
Let's see when I get it working. :-)
Quoted 22 lines
Quoted 3 lines
port before calling
openvpn(). Mayby I could add the exchange of address info here, since I don't think it needs to be transferred over a secure channel.Actually the temporary keys +
options_string()get passed over the secure TLS channel, so you could add further handshaking options and they would be secure.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
This way I have been able to keep those well tested procedures and protocol of openvpn untouched.
I still have some questions unsolved like DoS protection, dropping root priviledges and how to handel SIGUSR1 and SIGHUP.
It would be cool if we could get the forking server to work with dropping root privs.
Quoted 7 lines
One of the goals of dropping privs is that no datagram is ever read from the network with root privs.
It would be great if we could preserve this behavior.
Otherwise the split privileges model of the new openssh would be a possibility, but it's more complex.
For a forking server accepting connections from any ip, I consider it even more critical than for a peer2peer version.
I did it simply by calling set_user() in the server's main process and everything seems to work at least for me.
Don't know if this works in all cases since the server drops priviledges before opening tun dev.
Sampo