IPv6 client IP pool configuration issues (2.4/2.5)
Hi all,
Experimenting with OpenVPN 2.5 servers I noticed that issued IPv6 addresses to clients (pool) start at ::2 now instead of at ::1000 as was the case for OpenVPN 2.4.
As far as I can find, this is nowhere documented, neither that client IPs issued would start at ::1000 in OpenVPN 2.4, nor that it changed to ::2 in OpenVPN 2.5.
In order to not have the issued IP addresses change when using OpenVPN 2.5 I was looking in how to fix this and (for now) always use ::1000 no matter the version of OpenVPN on the server.
It doesn't seem to be as simple as adding the --ifconfig-ipv6-pool option to specify the pool when you are already using --server-ipv6.
This doesn't work:
--server-ipv6 fd42::/112
--ifconfig-ipv6-pool fd42::1000/112
However the OpenVPN manpage explains:
"Convenience-function to enable a number of IPv6 related options at once, namely --ifconfig-ipv6, --ifconfig-ipv6-pool and --push tun-ipv6."
However, it does not explain how it exactly would rewrite --server-ipv6 fd42::/112 to those three statements.
--ifconfig-ipv6 fd42::1/112 <????>
--ifconfig-ipv6-pool fd42::1000/112
--push "tun-ipv6"
What would the second parameter to --ifconfig-ipv6 be in this case? Looking through the server logging I see this (when using --server-ipv6):
2021-08-06 10:21:30 us=717290 bind_ipv6_only = DISABLED 2021-08-06 10:21:30 us=717881 ifconfig_ipv6_local = 'fd42::1' 2021-08-06 10:21:30 us=717994 ifconfig_ipv6_netbits = 112 2021-08-06 10:21:30 us=718149 ifconfig_ipv6_remote = 'fd42::2' 2021-08-06 10:21:30 us=720482 server_network_ipv6 = fd42:: 2021-08-06 10:21:30 us=720620 server_netbits_ipv6 = 112 2021-08-06 10:21:30 us=720841 push_entry = 'redirect-gateway def1 ipv6' 2021-08-06 10:21:30 us=721002 push_entry = 'tun-ipv6' 2021-08-06 10:21:30 us=721195 ifconfig_ipv6_pool_defined = ENABLED 2021-08-06 10:21:30 us=721265 ifconfig_ipv6_pool_base = fd42::2 2021-08-06 10:21:30 us=721337 ifconfig_ipv6_pool_netbits = 112 2021-08-06 10:21:30 us=721573 push_ifconfig_ipv6_defined = DISABLED 2021-08-06 10:21:30 us=721658 push_ifconfig_ipv6_local = ::/0 2021-08-06 10:21:30 us=721737 push_ifconfig_ipv6_remote = :: 2021-08-06 10:21:30 us=729301 do_ifconfig, ipv4=1, ipv6=1
The following line has something interesting:
2021-08-06 10:21:30 us=718149 ifconfig_ipv6_remote = 'fd42::2'
Would this mean the --server-ivp6 fd42::/112 expands to this?
OpenVPN 2.4:
--ifconfig-ipv6 fd42::1/112 fd42::2
--ifconfig-ipv6-pool fd42::1000/112
--push "tun-ipv6"
OpenVPN 2.5:
--ifconfig-ipv6 fd42::1/112 fd42::2
--ifconfig-ipv6-pool fd42::2/112
--push "tun-ipv6"
it does not seem to work (no traffic over VPN), and the output of the log:
2021-08-06 10:30:13 us=355589 bind_ipv6_only = DISABLED 2021-08-06 10:30:13 us=359889 ifconfig_ipv6_local = 'fd42::1' 2021-08-06 10:30:13 us=360355 ifconfig_ipv6_netbits = 112 2021-08-06 10:30:13 us=360500 ifconfig_ipv6_remote = 'fd42::2' 2021-08-06 10:30:13 us=367238 server_network_ipv6 = :: 2021-08-06 10:30:13 us=367761 server_netbits_ipv6 = 0 2021-08-06 10:30:13 us=368027 push_entry = 'tun-ipv6' 2021-08-06 10:30:13 us=368365 push_entry = 'redirect-gateway def1 ipv6' 2021-08-06 10:30:13 us=368876 ifconfig_ipv6_pool_defined = ENABLED 2021-08-06 10:30:13 us=369622 ifconfig_ipv6_pool_base = fd42::1000 2021-08-06 10:30:13 us=369767 ifconfig_ipv6_pool_netbits = 112 2021-08-06 10:30:13 us=370016 push_ifconfig_ipv6_defined = DISABLED 2021-08-06 10:30:13 us=370086 push_ifconfig_ipv6_local = ::/0 2021-08-06 10:30:13 us=370375 push_ifconfig_ipv6_remote = :: 2021-08-06 10:30:13 us=379916 do_ifconfig, ipv4=1, ipv6=1
Also in the config it seems to miss server_network_ipv6 and server_netbits_ipv6. How to specify those?
I feel I am missing something. Anyone knows what is going on here?
Thanks!
Regards,
François
Hi,
Quoted 6 lines · François Kooman
However, it does not explain how it exactly would rewrite --server-ipv6 fd42::/112 to those three statements.
--ifconfig-ipv6 fd42::1/112 <????>
--ifconfig-ipv6-pool fd42::1000/112
--push "tun-ipv6"
This should work. And you can leave off the "push" bit :-)
Quoted 1 line
What would the second parameter to --ifconfig-ipv6 be in this case?
A random IP in that subnet, like "fd42::1/112 fd42::2" - this is a somewhat unlucky artefact of the implementation of --ifconfig-ipv6, which insists on having a "remote" even if that is not used in many cases.
It is required in tap mode, to have "something to point route-ipv6 routes to" - default setting for --route-gateway-ipv6 - but since tun does not use next-hop IP addresses anyway, this is just stupid code.
Quoted 2 lines
2021-08-06 10:21:30 us=717994 ifconfig_ipv6_netbits = 112 2021-08-06 10:21:30 us=718149 ifconfig_ipv6_remote = 'fd42::2'
That should work :-)
[..]
Quoted 8 lines
Would this mean the --server-ivp6 fd42::/112 expands to this?
OpenVPN 2.4:
--ifconfig-ipv6 fd42::1/112 fd42::2
--ifconfig-ipv6-pool fd42::1000/112
--push "tun-ipv6"
Quoted 5 lines
OpenVPN 2.5:
--ifconfig-ipv6 fd42::1/112 fd42::2
--ifconfig-ipv6-pool fd42::2/112
--push "tun-ipv6"
Without having tested it, I would agree that this is what it is.
(The reason it was changed from :1000 to ::2 is "small pool size" - if you have only a /112 or smaller, starting from :1000 reduces the pool size significantly. If you use a /111 or bigger, it will actually stick to the old behaviour - see helper.c, around line 200)
Quoted 1 line
it does not seem to work (no traffic over VPN), and the output of the log:
The log snippet is too short to give meaningful advice. Please show the "ifconfig" or "ip address" statements, and what (if anything) is pushed to clients.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Quoted 1 line · Gert Doering
Hi,
Hi Gert,
Quoted 9 lines · François Kooman
Quoted 6 lines
However, it does not explain how it exactly would rewrite --server-ipv6 fd42::/112 to those three statements.
--ifconfig-ipv6 fd42::1/112 <????>
--ifconfig-ipv6-pool fd42::1000/112
--push "tun-ipv6"This should work. And you can leave off the "push" bit :-)
Ah right, that is implicit now (OpenVPN >= 2.4): "All tun devices on all platforms are always considered to be IPv6 capable. The --tun-ipv6 option is ignored (behaves like it is always on)."
Quoted 4 lines
A random IP in that subnet, like "fd42::1/112 fd42::2" - this is a somewhat unlucky artefact of the implementation of --ifconfig-ipv6, which insists on having a "remote" even if that is not used in many cases.
Right, I'll set it to the same IP as the tun0 device itself, i.e. fd42::1 if it can be random anyway ;-)
Quoted 1 line
Without having tested it, I would agree that this is what it is.
Actually I did test it now properly and it does work!
Quoted 4 lines
(The reason it was changed from :1000 to ::2 is "small pool size" - if you have only a /112 or smaller, starting from :1000 reduces the pool size significantly. If you use a /111 or bigger, it will actually stick to the old behaviour - see
helper.c, around line 200)
Right, thanks for the explanation!
Quoted 3 lines
The log snippet is too short to give meaningful advice. Please show the "ifconfig" or "ip address" statements, and what (if anything) is pushed to clients.
I actually screwed up my iptables rules that made it break because of different pool configuration (duh). So stupid :-(
Thanks for your reply and confirming it works like this! :-)
Regards,
François
Hi,
Quoted 8 lines · François Kooman
Quoted 8 lines · François Kooman
Quoted 6 lines
However, it does not explain how it exactly would rewrite --server-ipv6 fd42::/112 to those three statements.
--ifconfig-ipv6 fd42::1/112 <????>
--ifconfig-ipv6-pool fd42::1000/112
--push "tun-ipv6"
Quoted 5 lines
Quoted 1 line
This should work. And you can leave off the "push" bit :-)
Ah right, that is implicit now (OpenVPN >= 2.4): "All tun devices on all platforms are always considered to be IPv6 capable. The --tun-ipv6 option is ignored (behaves like it is always on)."
Yep. This is a very old option, which we still push in case a very old client connects. But it's really obsolete :-)
Quoted 7 lines
Quoted 4 lines
A random IP in that subnet, like "fd42::1/112 fd42::2" - this is a somewhat unlucky artefact of the implementation of --ifconfig-ipv6, which insists on having a "remote" even if that is not used in many cases.
Right, I'll set it to the same IP as the tun0 device itself, i.e. fd42::1 if it can be random anyway ;-)
In tun mode, that is fine. In TAP mode, you need a gateway for routes, but on the *server*, this needs a proper gateway address ("this client's IPv6 address") for routes to actually work, so it won't make a big difference there either :-)
Quoted 2 lines
Quoted 1 line
Without having tested it, I would agree that this is what it is.
Actually I did test it now properly and it does work!
Now that was easy ;-)
And - thanks for prompting me to go look and clean up that code. I have sent a patch to the list that removes the requirement for the second parameter to --ifconfig-ipv6, and "it seems to still work for me".
(So, in tun mode, no visible difference, and in tap mode, it will then refuse to install IPv6 routes unless --route-ipv6-gateway or a gateway parameter for --route-ipv6 is set up -> works as designed)
@Antonio: on that one, I would really appreciate if you could do a "full" review, with all the "route_ipv6_list" etc related code paths, if I have overlooked a corner case.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...