RFD - block-ipv6
Hi,
there's situation where you have a dual-stack IPv4+IPv6 client (like "most new end user connections in Germany these days"), and an IPv4-only OpenVPN setup - for whatever reason, like "running on an commercial system that is not using 2.3 yet" or the like.
Trying to access corporate resources in such an environment can be problematic if the resource has IPv4+IPv6, but your tunnel only has IPv4 and your client prefers IPv6 - it will try to connect "around" the tunnel, leading to a number of undesirable effects.
For the commercial OpenVPN client, I've hacked together something that mitigates this effect, by effectively breaking IPv6 connectivity while OpenVPN is running (so clients fall back to IPv4, which works through the tunnel). The option is called "block-ipv6", and currently works by setting up "reject" routes that immediately cause an ICMP unreachable to be sent when a client tries to connect to an IPv6 destination.
This works nicely on Linux, MacOS and Windows, and should work on other BSDs as well (not implemented yet). It does not work on Android or iOS, as you have no control over the real routing table, just the "routes into the VPN" - while those would prevent IPv6 communication "around" the VPN tunnel, it will have the not-so-nice property of causing client *timeouts*, instead of fast aborts due to immediate ICMP errors.
So, what I'm hoping to hear from you...
- should we include this in 2.3.3?
- if yes, are changes needed?
- should we try to implement something for 2.4/master that will work by pointing the IPv6 routes into the tunnel, and then synthesize the IPv6 ICMP errors inside OpenVPN? That would work on Android and iOS as well, and remove the extra per-platform logic for the "reject" routes
- any clever ideas how to achieve "full" IPv6 blocking (right now, it only kills the default route, but all more specific routes continue working - this is by design to keep the implementation simple, and was considered "good enough" by the end customer asking for it)
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...From 124e6c460e1bd42537c3e85753573176b4397d20 Mon Sep 17 00:00:00 2001
From: Gert Doering <[email protected]...>
Date: Fri, 16 Aug 2013 23:47:49 +0200
Subject: [PATCH] Add block-ipv6 functionality and option.
Block IPv6 traffic for situations when talking to an IPv4-only OpenVPN server, where IPv6 traffic must not "leak around" the VPN tunnel.
All we do is install a few more-specific IPv6 routes that result in block all "off-site" IPv6 traffic - no attempt is made to block LAN-local or link-local traffic or work around existing more specific routes.
Routes installed are: 2000::/4, 3000::/4, fc00::/7 (to cover default routes which might be installed as 2000::/3, plus ULA).
To use, simply push "block-ipv6" directive to client.
(Merged from OpenVPN SVN r8410, OpenVPN 2.1.22)
--- doc/openvpn.8 | 4 ++ src/openvpn/init.c | 8 ++++ src/openvpn/options.c | 6 +++ src/openvpn/options.h | 1 + src/openvpn/route.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/openvpn/route.h | 2 + 6 files changed, 122 insertions(+)
doc/openvpn.8 +4 -0
@@ -794,6 +794,10 @@ if no specific IPv6 TUN support for your OS has been compiled into OpenVPN. See below for further IPv6-related configuration options. .\"********************************************************* .TP +.B \-\-block-ipv6 +Block IPv6 traffic towards the Internet while VPN is up. +.\"********************************************************* +.TP .B \-\-dev-node node Explicitly set the device node rather than using /dev/net/tun, /dev/tun, /dev/tap, etc. If OpenVPN
src/openvpn/init.c +8 -0
@@ -1465,6 +1465,10 @@ do_open_tun (struct context *c)do_route (&c->options, c->c1.route_list, c->c1.route_ipv6_list, c->c1.tuntap, c->plugins, c->c2.es); +/* block IPv6 connectivity not going to the tunnel */ +if (c->options.block_ipv6) +route_block_ipv6 (c->c2.es); +/* * Did tun/tap driver give us an MTU? */
@@ -1562,6 +1566,10 @@ do_close_tun (struct context *c, bool force) c->c1.tuntap, ROUTE_OPTION_FLAGS (&c->options), c->c2.es); } +/* unblock IPv6 */ +if (c->options.block_ipv6) +route_unblock_ipv6 (c->c2.es); +/* actually close tun/tap device based on --down-pre flag */ if (!c->options.down_pre)do_close_tun_simple (c);
src/openvpn/options.c +6 -0
@@ -1434,6 +1434,7 @@ show_settings (const struct options *o)SHOW_STR (lladdr);SHOW_INT (topology);SHOW_BOOL (tun_ipv6); +SHOW_BOOL (block_ipv6);SHOW_STR (ifconfig_local);SHOW_STR (ifconfig_remote_netmask);SHOW_BOOL (ifconfig_noexec);
@@ -4310,6 +4311,11 @@ add_option (struct options *options,VERIFY_PERMISSION (OPT_P_UP ); options->tun_ipv6 = true; } +else if (streq (p[0 ],"block-ipv6" )) + { +VERIFY_PERMISSION (OPT_P_UP ); + options->block_ipv6 = true; + }#ifdef ENABLE_IPROUTE else if (streq (p[0], "iproute") && p[1]) {
src/openvpn/options.h +1 -0
@@ -257,6 +257,7 @@ struct optionsint ping_rec_timeout;/* Expect a TCP/UDP ping from remote at least once every n seconds */ bool ping_timer_remote;/* Run ping timer only if we have a remote address */ bool tun_ipv6;/* Build tun dev that supports IPv6 */ +bool block_ipv6;/* block all IPv6 not going to the tun */ # define PING_UNDEF 0# define PING_EXIT 1
src/openvpn/route.c +101 -0
104 lines not on this page · raw message
src/openvpn/route.h +2 -0
@@ -278,6 +278,8 @@ bool is_special_addr (const char *addr_str);void get_default_gateway (struct route_gateway_info *rgi);void print_default_gateway (const int msglevel,const struct route_gateway_info *rgi); +void route_block_ipv6 (const struct env_set *es); +void route_unblock_ipv6 (const struct env_set *es);/* * Test if addr is reachable via a local interface (return ILA_LOCAL),
Signature · 1 line
1.8.1.5
Am 17.08.13 12:30, schrieb Gert Doering:
Quoted 28 lines
Hi,
there's situation where you have a dual-stack IPv4+IPv6 client (like "most new end user connections in Germany these days"), and an IPv4-only OpenVPN setup - for whatever reason, like "running on an commercial system that is not using 2.3 yet" or the like.
Trying to access corporate resources in such an environment can be problematic if the resource has IPv4+IPv6, but your tunnel only has IPv4 and your client prefers IPv6 - it will try to connect "around" the tunnel, leading to a number of undesirable effects.
For the commercial OpenVPN client, I've hacked together something that mitigates this effect, by effectively breaking IPv6 connectivity while OpenVPN is running (so clients fall back to IPv4, which works through the tunnel). The option is called "block-ipv6", and currently works by setting up "reject" routes that immediately cause an ICMP unreachable to be sent when a client tries to connect to an IPv6 destination.
This works nicely on Linux, MacOS and Windows, and should work on other BSDs as well (not implemented yet). It does not work on Android or iOS, as you have no control over the real routing table, just the "routes into the VPN" - while those would prevent IPv6 communication "around" the VPN tunnel, it will have the not-so-nice property of causing client *timeouts*, instead of fast aborts due to immediate ICMP errors.
So, what I'm hoping to hear from you...
Quoted 7 lines
- should we include this in 2.3.3?
- if yes, are changes needed?- should we try to implement something for 2.4/master that will work by pointing the IPv6 routes into the tunnel, and then synthesize the IPv6 ICMP errors inside OpenVPN? That would work on Android and iOS as well, and remove the extra per-platform logic for the "reject" routes
I am in favour of this. There is also another VPN breakage that could be adressed by this. Sometimes the apps try use old sockets until they are getting a timeout. RST/icmp unreable for packets with a wrong source IP could be handled as well.
Arne
Am 17.08.2013 12:30, schrieb Gert Doering:
Quoted 4 lines
So, what I'm hoping to hear from you...
- should we include this in 2.3.3?
- if yes, are changes needed?
Well, it would take huge warning banners because it might disrupt existing setups (which would be insecure through the "connect around tunnel" behaviour), so I'd prefer "2.4" with a sooner 2.4 release.
Quoted 4 lines
- should we try to implement something for 2.4/master that will work by pointing the IPv6 routes into the tunnel, and then synthesize the IPv6 ICMP errors inside OpenVPN? That would work on Android and iOS as well, and remove the extra per-platform logic for the "reject" routes
Absolutely, on both accounts, if technically feasible. You may need to synthesize RST for stale TCP sockets, and ICMP for UDP, too.
Quoted 4 lines
- any clever ideas how to achieve "full" IPv6 blocking (right now, it only kills the default route, but all more specific routes continue working - this is by design to keep the implementation simple, and was considered "good enough" by the end customer asking for it)
End users may also have requirements to override certain more specific routes to bypass the tunnel. I can fancy only few things that are worse than flipping global connection status "with/without VPN" every few minutes if you need host and "home" resources at the same time.
Use case is for guests in a "host" LAN that need the VPN for the default route and "home" networks, but need to access local organizer (host) information, too. And very common during symposiums, conferences, and thereabouts.
Like: you visit another place, and you need access to the journals of your home university, but at the same time the organizer uploaded documents for collaborative work or you need local public transport schedules.
I found myself using the "permit local specific routes" switch quite often to avoid dis-/reconnecting all the time. That was with "all IPv4", however.
Hi,
Quoted 10 lines · Matthias Andree
Am 17.08.2013 12:30, schrieb Gert Doering:
Quoted 4 lines
So, what I'm hoping to hear from you...
- should we include this in 2.3.3?
- if yes, are changes needed?Well, it would take huge warning banners because it might disrupt existing setups (which would be insecure through the "connect around tunnel" behaviour), so I'd prefer "2.4" with a sooner 2.4 release.
Well, it would not happen "automatically", but only if block-ipv6 is configured or pushed from the server (and if the server pushes it to a 2.3.2 client, that one would not silently ignore it but abort) - so I do not see much potential for breaking existing setups here, unless the admin is intentionally turning it on...
Quoted 7 lines
Quoted 4 lines
- should we try to implement something for 2.4/master that will work by pointing the IPv6 routes into the tunnel, and then synthesize the IPv6 ICMP errors inside OpenVPN? That would work on Android and iOS as well, and remove the extra per-platform logic for the "reject" routes
Absolutely, on both accounts, if technically feasible. You may need to synthesize RST for stale TCP sockets, and ICMP for UDP, too.
I hear you and Arne, and will go out and start coding... :-)
Quoted 9 lines
Quoted 4 lines
- any clever ideas how to achieve "full" IPv6 blocking (right now, it only kills the default route, but all more specific routes continue working - this is by design to keep the implementation simple, and was considered "good enough" by the end customer asking for it)
End users may also have requirements to override certain more specific routes to bypass the tunnel. I can fancy only few things that are worse than flipping global connection status "with/without VPN" every few minutes if you need host and "home" resources at the same time.
Indeed. Besides the technical challenge, this would of course need to be configurable ("block-ipv6 all" vs. "block-ipv6 default-route-only" or so).
The technical challenge of actually making this work in scenarios where VPN policy requires "no other access" is even more interesting, given that IPv6 routes/prefixes might change dynamically on a host with IPv6 autoconfig enabled...
gert
Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
//www.muc.de/~gert/
Gert Doering - Munich, Germany [email protected]...
fax: +49-89-35655025 [email protected]...