M
M
m2_viktor2016-05-01 09:52:25
openvpn
m2_viktor, 2016-05-01 09:52:25

How to raise 2 openvpn tunnels (udp) at the same time?

Hello, virtualbox has two openvpn servers and a client (all debian8) that use the udp protocol. The client connects to both servers at the same time, when connecting to the second one, an error appears:
TCP/UDP: Socket bind failed on local address [undef]: Address already in
use
netstat -u on the client returns empty tcp 0 0 client.lan:51801
ovpn2.lan
:10883 ESTABLISHED
tcp 0 0 client.lan:49416 ovpn1.lan:10882
ESTABLISHED listening socket:
A listening tcp socket, when a connection is established with it, creates a copy of itself and a connection is established with a copy already, a listening udp socket simply receives a datagram without establishing a connection, on one socket, from any number of clients. And I think it has something to do with my situation.
Help me to understand.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AlexeySetevoi, 2016-05-03
@m2_viktor

Here is the mechanics, the default behavior of the current version of openvpn is different for tcp and udp.
For tcp connections from an openvpn client, by default, it automatically selects an unoccupied non-privileged port on the client machine and uses it in connection with the server, so it turns out fine, something like this:

tcp        0      0 client:46788            ovpn1:10882             ESTABLISHED 2320/openvpn    
tcp        0      0 client:38172            ovpn2:10882             ESTABLISHED 2322/openvpn

For udp, openvpn with your configs will not select the port automatically on the client - but will try to hang the process on the local port 1194. The first client that managed to make a connection will normally contact the server and take 1194. The second and subsequent clients with such configs will try to take 1194 - and will receive otlup - which is observed in the error.
Quick options to get around this - either register the local occupied port in the client config, statically add the option to each client config:
lport 44455 - первому клиенту
lport 44456 - второму клиенту

or, specify an option
nobindin each config, in this case, openvpn will do the assignment of local ports in the same way as tcp automatically.
In general, the task of choosing a local unoccupied port automatically for tcp and udp is fundamentally the same as bind () or connect () depending on where - therefore, this behavior, in my opinion, is the personal behavior of openvpn dictated by the considerations of its community, without any obligatory binding to the theory .

P
paxlo, 2016-05-05
@paxlo

In the client config, remove the
the remote line to the form
remote ip-vpn-server udp port (or tcp whatever you have there)
Add
line to end up with:
remote 192.168.192.10 1194 udp
nobind

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question