Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Enable "regular" network traffic when using VPN
Date: Tue, 19 Jun 2018 11:58:13
Message-Id: 2085780.9XL98ARuzO@dell_xps
In Reply to: Re: [gentoo-user] Enable "regular" network traffic when using VPN by Grant Taylor
1 On Monday, 18 June 2018 15:37:00 BST Grant Taylor wrote:
2 > On 06/18/2018 04:30 AM, Mick wrote:
3
4 > > The above does not offer him a route into the company's LAN and he cannot
5 > > connect to the servers *.i.company.com.
6 >
7 > Small nuance that routes don't deal with names and that names must be
8 > translated to IPs. But that does require making sure there are routes
9 > to the proper name server to do said translation.
10
11 Yes, domain name resolution for remote hosts within the remote LAN space has
12 to happen before routing to an IP address takes place. If these remote
13 machines are not publicly accessible, Hilco's PC will need to have configured
14 his company's nameservers.
15
16 Some (all?) VPN clients use scripts to achieve this once a connection with the
17 remote peer has taken place. Many distros use dnsmasq to set up separate
18 nameservers for split tunnels. With Gentoo (without dnsmasq) I have found the
19 remote peer's nameservers are written in resolv.conf by the VPN client Up
20 script, but only for full tunnels. I've noticed with strongswan when setting
21 up split tunnels it errors out as it tries to set a nameserver for the tunnel
22 side and ends up with the local default gateway nameserver only. Of course
23 remote peer private name space resolutions fail, because the local nameserver
24 does not know anything about them.
25
26 Actually, I don't know if there is a way to set up multiple nameservers for
27 corresponding name resolution in/out of the tunnel, without using a domain-
28 specific override as you would with dnsmasq and without leaking DNS queries to
29 the ISP if you are meant to be querying the tunnel's nameservers.
30
31
32 > > When the above setting is left disabled, then Hilco can access the company
33 > > domain, but not the Internet - a full tunnel. His route table now shows
34 > > tun0 as being the default NIC:
35 >
36 > It seems like you're using "full tunnel" to mean that everything is
37 > routed through the tunnel. Save for the VPN tunnel traffic itself.
38 >
39 > I figured that's what you meant, but I wanted to ask and be sure.
40 >
41 > > My understanding of a "split tunnel" or "split horizon" as you call it
42 > > involves two routes:
43 > >
44 > > 1. Route for connections via the VPN tunnel:
45 > >
46 > > One route is used to direct datagrams from a local subnet or a virtual
47 > > VPN IP allocated by the remote VPN gateway, e.g. $SOME_COMPANY_IP_1,
48 > > via the VPN tunnel (tun0) to the remote company's LAN.
49 > >
50 > > 2. Route for all other connections, outside the VPN tunnel:
51 > >
52 > > A second route is typically the default route of the PC for all other
53 > > connections and it is used to route datagrams outside the VPN tunnel.
54 >
55 > Agreed. Though there may be more routes for additional subnets routed
56 > through the VPN. This is what I think Hilco is wanting to do.
57 >
58 > > Some VPN clients add a new routing policy rule table (e.g. strongswan),
59 > > but others (e.g. racoon) add routes for the VPN tunnel in the main
60 > > routing policy rule table.
61 >
62 > I was not aware that any VPNs used alternate routing tables and rules to
63 > use them. But that does make sense. Programmatically, that may be
64 > simpler to maintain and clean up after the VPN is shut down too. I.e.
65 > assume that anything in the routing table is for the VPN and safe to
66 > remove, along with the single predictable rule referencing said table.
67
68 Yes, those VPN implementations that set up separate routing policy tables help
69 to keep main and 'VPN' rules separate, which is neat and easy to maintain.
70 From memory Strongswan in particular sets up a rule table with ID 220, which
71 only contains the route from the local VPN subnet to the remote LAN subnet.
72
73
74 > > In contrast, a "full tunnel" directs all outgoing datagrams from any
75 > > local subnet via the VPN.
76 >
77 > I agree at a high level. The nuanced nitpicks don't matter at this point.
78 >
79 > > I appreciate what I describe above is inverse to what the setting "Use
80 > > only for resources on this connection" is meant to do, but I merely go
81 > > by the route tables Hilco has provided.
82 >
83 > My not-yet-awake brain doesn't see the inverse issue that you're
84 > referring to. But I'm used to dealing with VPNs, so maybe something is
85 > instinctive for me.
86 >
87 > > Hmm ... prompted by your question in this post I had to give it a second
88 > > thought, and I've come up with this hypothesis:
89 > >
90 > > IF no specific subnet routes are defined on the NM routes tab AND the "Use
91 > > only for resources on this connection" is selected, then it may be that
92 > > networkmanager translates no subnet entry to mean 0.0.0.0/0 - ALL routes
93 > > will be tunneled via the VPN, leaving nothing for the default route.
94 >
95 > Using a (translated or not) route of "0.0.0.0/0" seems antithetical to
96 > "Use only for resources on this connection".
97
98 Quite. The user (or his VPN client via some NM plugin) is meant to add in
99 this networkmanager IPv4/Route tab the remote LAN subnet(s) and enable "Use
100 only for resources on this connection" in order to set up a split tunnel.
101 Then tun0 will only be used to tunnel connections to these subnets. All other
102 connections to the Internet or local LAN will go outside the tunnel, using the
103 default local gateway.
104
105 Given Hilco's results I'm surmising an empty table in the NM translates as
106 0.0.0.0/0 and all connections end up being routed via the VPN stack, but I
107 could be wrong because I don't know what he may have entered in this table.
108
109 I recall a couple of years ago playing with AppleMac's NM settings to
110 configure a split tunnel, but gave up on this route table palaver, because it
111 was not behaving rationally at the time - or so I thought. I couldn't achieve
112 a split tunnel using it, so I used the cli to set up routes for the remote
113 peer's subnet.
114
115
116 > > Without more information on NM's specific settings I'm not sure why
117 > > routing is screwed up like this. :-)
118 >
119 > I don't think it is screwed up. Enabling "Use only for resources on
120 > this connection" doesn't change the default route. Disabling "Use only
121 > for resources on this connection" does change the default route.
122
123 Yes, but leaving the routes table empty ... it seems to tunnel everything
124 through it ... I don't know without trying it out myself or getting more info
125 on the settings.
126
127
128 > It does look like NetworkManager has the concept of additional routes
129 > that should be routed through the VPN. However when hovering over the
130 > box that I think you enter them in, "Editing IPv4 routes for VPN
131 > connection $NAME", I get a tool tip balloon that says "IP addresses
132 > identify your computer on the network. Click the Add button to add an
133 > IP address.". Which makes one think the dialog box is for enter IP
134 > addresses. However I suspect that's an artifact of how the dialog box
135 > is constructed and re-using the same code as for entering IPs. The
136 > Address, Netmask, Gateway, and Metric fields do sound like routes.
137 > Though I question the wisdom of a static gateway in this case verses the
138 > tunnel device.
139
140 I expect you can set up a subnet here and from this the NM will configure the
141 route accordingly to make it go through the VPN stack.
142
143
144 > > Nevertheless, adding a route manually for the remote LAN subnet as per
145 > > my previous post should deliver a 'split tunnel/horizon', assuming the
146 > > DNS nameservers are also somehow sorted out.
147 >
148 > I suspect that the client needs to be directed to use the DNS servers on
149 > the corporate LAN and ensure that their IPs / networks are also routed
150 > through the LAN.
151 >
152 > Or do something creative like run a local DNS server that knows to send
153 > queries for company.com to a DNS server through the VPN.
154
155 As I've mentioned above I've noticed strongswan fails to set up split tunnel
156 DNS nameservers, or may be something is misconfigured on the remote peer's VPN
157 gateway. Is this something I can manipulate via resolv.conf on the local PC
158 (without a local resolver) to make sure DNS searches meant for the VPN stack
159 are tunneled to the remote nameservers not leaked outside it?
160
161 PS. Thanks for your write up on network namespaces. I'll look into this in
162 more depth when I get a minute, because I would like to contain/isolate
163 desktop applications I inherently mistrust - e.g. Skype.
164
165 --
166 Regards,
167 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Enable "regular" network traffic when using VPN Grant Taylor <gtaylor@×××××××××××××××××××××.net>