RFE: allow 'lport 0' setup for random port binding
Hi,
I am running a multihomed host where 'local <extip>' must be specified for proper operation. Unfortunately, this implies 'lport 1194' or another static port.
This causes problems with stateful firewalls which register the host/port pairs in the internal connection tracking table. On ungraceful reconnects, the new TCP connection will have same the host/port pairs but unexpected sequence numbers. The new connection will be assumed as invalid hence and be dropped.
It would be nice when local port can be configured to be bound to a random port number. After reading code,
| else if (streq (p[0], "lport") && p[1])
| ...
| port = atoi (p[1]);
|- if (!legal_ipv4_port (port))
|+ if (port != 0 && !legal_ipv4_port (port))
| {in options.c seems to be the only required change.
Enrico
[Openvpn-devel] RFE: allow 'lport 0' setup for random port binding (arrived in [Openvpn-users])
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Resending it to openvpn-devel list, to hit the right audience.
kind regards,
David Sommerseth
Quoted 22 lines · Enrico Scholz
Hi,
I am running a multihomed host where 'local <extip>' must be specified for proper operation. Unfortunately, this implies 'lport 1194' or another static port.
This causes problems with stateful firewalls which register the host/port pairs in the internal connection tracking table. On ungraceful reconnects, the new TCP connection will have same the host/port pairs but unexpected sequence numbers. The new connection will be assumed as invalid hence and be dropped.
It would be nice when local port can be configured to be bound to a random port number. After reading code,
| else if (streq (p[0], "lport") && p[1]) | ... | port = atoi (p[1]); |- if (!legal_ipv4_port (port)) |+ if (port != 0 && !legal_ipv4_port (port)) | {
Quoted 5 lines
in
options.cseems to be the only required change.Enrico
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAktHTyMACgkQDC186MBRfrrceACfT7IdVvNZU5VxIVQG1A19pmue 4dEAn1FEYwDky5BekueF/rELX7jVOfUK
=zjPt
-----END PGP SIGNATURE-----
Quoted 2 lines · Enrico Scholz
I am running a multihomed host where 'local <extip>' must be specified for proper operation.
Could you add a route and use nobind? Unless you have one openvpn on each IP that should work.
(I usually take multihomed to mean multi network rather than several IP addresses on one and the same network.)
Quoted 3 lines
On ungraceful reconnects, the new TCP connection will have same the host/port pairs but unexpected sequence numbers. The new connection will be assumed as invalid hence and be dropped.
I would actually expect the firewall to notice that there is a new connection. Since it doesn't, maybe you can explicitly allow this traffic?
OpenVPN can certainly be made to do what you describe, but it seems that there are more ways to solve the problem, and one of those might suit you better. I know I would prefer fixing the firewall rules.
//Peter
Quoted 5 lines · Peter Stuge
Quoted 2 lines
I am running a multihomed host where 'local <extip>' must be specified for proper operation.
Could you add a route and use nobind? Unless you have one openvpn on each IP that should work.
I would really like to avoid the NAT hackery.
Quoted 7 lines
Quoted 3 lines
On ungraceful reconnects, the new TCP connection will have same the host/port pairs but unexpected sequence numbers. The new connection will be assumed as invalid hence and be dropped.
I would actually expect the firewall to notice that there is a new connection. Since it doesn't, maybe you can explicitly allow this traffic?
I do not have access to this firewall.
Quoted 3 lines
OpenVPN can certainly be made to do what you describe, but it seems that there are more ways to solve the problem, and one of those might suit you better.
I think, supporting common TCP/UDP client functionality (which choses random source ports) suits my needs best. I do not see reasons why 'local' must be tied to 'lport'.
Quoted 1 line
I know I would prefer fixing the firewall rules.
I would prefer to fix openvpn ;)
Enrico
Quoted 7 lines · Enrico Scholz
Quoted 5 lines
Quoted 2 lines
I am running a multihomed host where 'local <extip>' must be specified for proper operation.
Could you add a route and use nobind? Unless you have one openvpn on each IP that should work.
I would really like to avoid the NAT hackery.
I didn't mean to suggest any NAT. If you have access to the system that is running openvpn I think you could add routes to the routing table in that system which will remove the need for openvpn to explicitly bind at all. Applications that do not bind() are assigned source address according to the system routing table. Of course this will affect all processes on the system, not only openvpn.
Quoted 5 lines
Quoted 3 lines
I would actually expect the firewall to notice that there is a new connection. Since it doesn't, maybe you can explicitly allow this traffic?
I do not have access to this firewall.
Can you reach someone who does? I guess the VPN working right is in their interest too, and..
Quoted 3 lines
Quoted 1 line
I know I would prefer fixing the firewall rules.
I would prefer to fix openvpn ;)
..I maintain that the problem is actually with the firewall that doesn't notice the new connection. (I guess because of too simplistic packet inspection?)
Quoted 3 lines
I think, supporting common TCP/UDP client functionality (which choses random source ports) suits my needs best. I do not see reasons why 'local' must be tied to 'lport'.
The source IP and source port are specified using one and the same system call; bind(). It's likely that when developing the binding options it was simply thought that either both can be specified, or neither will be neccessary. Perhaps specifically because firewalls usually do connection tracking better than the one you're dealing with. :\
//Peter
Quoted 9 lines · Peter Stuge
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I am running a multihomed host where 'local <extip>' must be specified for proper operation.
Could you add a route and use nobind? Unless you have one openvpn on each IP that should work.
I would really like to avoid the NAT hackery.
I didn't mean to suggest any NAT.
NAT would be required on a multihomed host with a routable external and an unroutable internal IP where the internal one is the primary address of the outgoing interface.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I would actually expect the firewall to notice that there is a new connection. Since it doesn't, maybe you can explicitly allow this traffic?
I do not have access to this firewall.
Can you reach someone who does? I guess the VPN working right is in their interest too, and..
The firewall is completely ok. A TCP connection is identified by a src<ip:port> + dst<ip:port> pair. When the firewall has recorded an active TCP connection and a TCP packet arrives with a corresponding pair but unexpected flags (e.g. SYN) or sequence numbers, this packet is detected as invalid and be dropped.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
I know I would prefer fixing the firewall rules.
I would prefer to fix openvpn ;)
..I maintain that the problem is actually with the firewall that doesn't notice the new connection. (I guess because of too simplistic packet inspection?)
no; it is because the OpenVPN client creates the same src + dst pair for every connection. I suggest to read some papers about stateful firewalls before continuing this discussion.
Enrico
Quoted 4 lines · Enrico Scholz
no; it is because the OpenVPN client creates the same src + dst pair for every connection. I suggest to read some papers about stateful firewalls before continuing this discussion.
Enrico is right. It's in the IP RFC, the 2MSL (twice the maximum segment lifetime) rule. (STD 5 is the right rfc?)
I haven't otherwise been following the discussion, but if there's no other way to do what he wants to do with OpenVPN then OpenVPN is violating the RFC.
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
Let's try some more.
Quoted 5 lines · Karl O. Pinc
Quoted 2 lines
no; it is because the OpenVPN client creates the same src + dst pair for every connection.
Enrico is right. It's in the IP RFC, the 2MSL (twice the maximum segment lifetime) rule. (STD 5 is the right rfc?)
I agree that the statement about TCP/UDP 4-tuple is correct for the two participating systems. They identify the connection that way, and it's even easy to see as a user with something basic such as netstat. Internally they of course store lots of other information related to the connection, associated to the 4-tuple.
Quoted 3 lines
I haven't otherwise been following the discussion, but if there's no other way to do what he wants to do with OpenVPN then OpenVPN is violating the RFC.
My point is that a "stateful" firewall should keep more info about connections than just a 4-tuple. The firewall that is causing Enrico trouble seems to not do this, since it does not recognize a new connection if uses the same 4-tuple. To me, that actually sounds like the textbook definitition of a _stateless_ firewall. :)
I am convinced that it is simpler to add code to OpenVPN to work around this problem, than to fix the firewall, but I still don't think this is really a fault in OpenVPN. I'm just another user though.
//Peter
Quoted 7 lines · Peter Stuge
Let's try some more.
Quoted 1 line · Karl O. Pinc
Quoted 1 line
no; it is because the OpenVPN client creates the same src + dst
pair
Quoted 2 lines
Quoted 1 line
for every connection.
Quoted 8 lines
Quoted 2 lines
Enrico is right. It's in the IP RFC, the 2MSL (twice the maximum segment lifetime) rule. (STD 5 is the right rfc?)
My point is that a "stateful" firewall should keep more info about connections than just a 4-tuple. The firewall that is causing Enrico trouble seems to not do this, since it does not recognize a new connection if uses the same 4-tuple. To me, that actually sounds like the textbook definitition of a _stateless_ firewall. :)
Please read the RFC. A TCP connection should not re-use the 4-tuple for a limited interval of time after connection close. A corollary, which is only clear once you understand the purpose of this restriction, is that a good firewall should interpret violations of this rule as an attempt to inject data into the closed TCP connection and should block such traffic.
Note that Microsoft TCP stacks have been known to violate this rule. This is no excuse; it's an indication that the stack should not be relied on to perform in a standards compliant fashion.
Karl <[email protected]...>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein