Re: [Dorset] Wimborne Model Town Routing Problem

2022-04-18 Thread Terry Coles
On Monday, 18 April 2022 20:26:36 BST Patrick Wigmore wrote:
> I suppose one thing to check is whether, while connected to the VPN,
> you have any other (conflicting) routes to 192.168.0.0/24. Or, indeed,
> whether there is a route to 192.168.0.0/24 at all. E.g. run
> 
> $ ip route show
> 
> on your VPN client computer and see where it thinks it should send
> traffic destined for 192.168.0.0/24.

Here it is:

terry@OptiPlex:~/Useful$ ip route show
default via 192.168.1.1 dev eno1 proto dhcp metric 100 
169.254.0.0/16 dev eno1 scope link metric 1000 
192.168.1.0/24 dev eno1 proto kernel scope link src 192.168.1.21 metric 100

-- 



Terry Coles



-- 
  Next meeting: Online, Jitsi, Tuesday, 2022-05-03 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Wimborne Model Town Routing Problem

2022-04-18 Thread Hamish McIntyre-Bhatty

On 18/04/2022 20:26, Patrick Wigmore wrote:

On Mon, 18 Apr 2022 10:23:19 +0100, Terry Coles wrote:

When a VPN client connects to the Web Server, in theory the web
server would see that connection coming in from a 10.1.10.0/24
address, not a 192.168.0.0/24 one. So, it is a given that the
Webserver has to be configured to accept connections from
10.1.10.0/24 clients.

So how would I do that?  I always assumed that the VPN Server
included a router that would sort all that out.  The iptables
output would indicate that it does.

I suppose there is some nuance here; the connection would come from a
10.1.10.0/24 address, routed via the 192.168.0.0/24 address of the VPN
server. So, the Webserver would see that 192.168.0. had forwarded it
some traffic that originated from 10.1.10.x.

If the VPN server were doing NAT routing/masquerading, as opposed to
plain old routing, then the connection would appear to come directly
from the VPN server's 192.168.0.0/24 address. I suppose the VPN server
*could* be doing NAT routing, but that would be a little surprising to
me, because I am not seeing how NAT routing would be beneficial in
this set-up.

But I only mentioned this in case you had configured the server to
block connections that weren't from 192.168.0.0/24 addresses, so if
you haven't done that then I can't see it being a concern.

The only other thing that comes to mind on a brief reading of your
response to me is that, if the web server isn't accessible by IP
address, then it certainly isn't going to be accessible via hostname.

So, as you say, the routing falls under suspicion.

The finer points of iptables configuration are perhaps a bit lost on
me, so while I can look at the broad-strokes of your config, and I
think it seems OK, I could easily be missing some nuances that might
send it off the rails.

I suppose one thing to check is whether, while connected to the VPN,
you have any other (conflicting) routes to 192.168.0.0/24. Or, indeed,
whether there is a route to 192.168.0.0/24 at all. E.g. run

 $ ip route show

on your VPN client computer and see where it thinks it should send
traffic destined for 192.168.0.0/24.

That raises the question of how the VPN client learns which networks
it can route to via the VPN. Presumably it does learn something, since
you can access the various non-Webserver devices in the 192.168.0.0/24
network. Unless that's happening by fluke.

If there isn't a suitable route to 192.168.0.0/24 on the VPN client
computer, then manually adding one temporarily might be a worthwhile
experiment.

It seems you've got me hooked on this puzzle, Terry. I was only going
to write a few paragraphs here, to clarify my previous remarks!

Patrick


Note: The VPN Server does not do NAT, as is evidenced by the "Last login 
from 10.1.10.x" prompt that I get after SSHing into one of the pis 
periodically.


Hamish


--
 Next meeting: Online, Jitsi, Tuesday, 2022-05-03 20:00
 Check to whom you are replying
 Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
 New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Wimborne Model Town Routing Problem

2022-04-18 Thread Patrick Wigmore
On Mon, 18 Apr 2022 10:23:19 +0100, Terry Coles wrote:
> > When a VPN client connects to the Web Server, in theory the web
> > server would see that connection coming in from a 10.1.10.0/24
> > address, not a 192.168.0.0/24 one. So, it is a given that the
> > Webserver has to be configured to accept connections from
> > 10.1.10.0/24 clients.
> So how would I do that?  I always assumed that the VPN Server
> included a router that would sort all that out.  The iptables
> output would indicate that it does.

I suppose there is some nuance here; the connection would come from a 
10.1.10.0/24 address, routed via the 192.168.0.0/24 address of the VPN 
server. So, the Webserver would see that 192.168.0. had forwarded it 
some traffic that originated from 10.1.10.x.

If the VPN server were doing NAT routing/masquerading, as opposed to 
plain old routing, then the connection would appear to come directly 
from the VPN server's 192.168.0.0/24 address. I suppose the VPN server 
*could* be doing NAT routing, but that would be a little surprising to 
me, because I am not seeing how NAT routing would be beneficial in 
this set-up.

But I only mentioned this in case you had configured the server to 
block connections that weren't from 192.168.0.0/24 addresses, so if 
you haven't done that then I can't see it being a concern.

The only other thing that comes to mind on a brief reading of your 
response to me is that, if the web server isn't accessible by IP 
address, then it certainly isn't going to be accessible via hostname.

So, as you say, the routing falls under suspicion.

The finer points of iptables configuration are perhaps a bit lost on 
me, so while I can look at the broad-strokes of your config, and I 
think it seems OK, I could easily be missing some nuances that might 
send it off the rails.

I suppose one thing to check is whether, while connected to the VPN, 
you have any other (conflicting) routes to 192.168.0.0/24. Or, indeed, 
whether there is a route to 192.168.0.0/24 at all. E.g. run

$ ip route show

on your VPN client computer and see where it thinks it should send 
traffic destined for 192.168.0.0/24.

That raises the question of how the VPN client learns which networks 
it can route to via the VPN. Presumably it does learn something, since 
you can access the various non-Webserver devices in the 192.168.0.0/24 
network. Unless that's happening by fluke.

If there isn't a suitable route to 192.168.0.0/24 on the VPN client 
computer, then manually adding one temporarily might be a worthwhile 
experiment.

It seems you've got me hooked on this puzzle, Terry. I was only going 
to write a few paragraphs here, to clarify my previous remarks!

Patrick



-- 
  Next meeting: Online, Jitsi, Tuesday, 2022-05-03 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk


Re: [Dorset] Wimborne Model Town Routing Problem

2022-04-18 Thread Terry Coles
Patrick,

Thanks for your extremely detailed response; it's taken me a while to get 
through it and I hope that I've understood what you are saying properly.

BTW.  I've learned quite a bit :-)

See my responses below.

On Sunday, 17 April 2022 15:17:04 BST Patrick Wigmore wrote:
> If I understand you correctly, I think you are saying that each device
> on the WMT Network is allocated an address in the 10.1.10.0/24 range.
> This does not make sense. Why would the WMT Network devices need
> 10.1.10.0/24 addresses, in addition to their 192.168.0.0/24 ones?

I'm not sure where the information came from regarding the 10.1.10.0/24 
address range; probably in one of my many conversations with the author of 
pistrong.  It looks like I misunderstood him.

> This also means that the VPN clients will not be getting told about
> the 192.168.0.1 DNS server via DHCP, so they won't automatically use
> it. This means their traffic won't get forwarded to the web server
> automatically. If you wanted them to know about that DNS server, you
> would need to configure the VPN server to tell them about it. They
> won't discover it automatically via DHCP like an on-site network
> client would.

According to the author of pistrong they are.  Here is a part of the Query/
Response session that pistrong generates during installation and configuration 
of the server:

DNS Server for connected VPN clients: 192.168.0.1,8.8.8.8

The bit before the : is the Query and the rest is my response.  You can see 
that the system has the information and should provide it to the client during 
negotiation.  However, there appears to be no path to 192.168.0.1 from the 
client in use and so (I assume) the client drops it and only 8.8.8.8 remains.  
(However see below.)

Early in the development process the author of pistrong suggested that I add 
the 8.8.8.8 to that response so that the client could still access the 
Internet while connected to the WMT Network via the VPN Server.

> Be aware that VPN clients will sometimes use a VPN-provided DNS server
> for EVERYTHING, which could have the effect of intercepting DNS
> queries for traffic that has nothing to do with the VPN, which might
> break networking for things that are running on the same machine as
> the VPN client, and could cause a privacy issue. If possible, it may
> be better to configure the VPN clients so that the WMT DNS server is
> only used to query domain names that are part of the WMT network.

The WMT DNS Server does only provide IP Addresses for the hosts on the WMT 
Network.  Putting together your comment about privacy and my old IT Manager's 
reaction when someone at work 'bridged' the network, I see that this wasn't a 
particularly good idea.

> So, when you said:
> > The VPN Server doesn't know the IP Address of the
> > Webserver, but it doesn't need to because all traffic should be
> > forwarded to it.
> 
> The second part of the statement was untrue. The VPN server DOES need
> to know the IP address of the Webserver (assuming you want it to tell
> its clients), because the automatic forwarding to the Webserver only
> works for DHCP clients in the local network.

I think there may be a misconception here.  When I said forwarding, I meant 
that any queries in the 192.168.0.0/21 subnet should be forwarded to all the 
devices in that subnet.  That would include the Webserver on 192.168.0.1.  
However for that to happen the VPN Client clearly needs to know that that IP 
Address provides a DNS Server and for some reason it either doesn't or it does 
and it can't get there (see below)

> Do you mean that it does not work automatically, or do you mean that
> clients logged in via the VPN cannot query this server at all. What
> happens if you say explicitly which server to query, by doing:
> 
> $ dig @192.168.0.1 [webserver domain name]
> 
> or
> 
> $ nslookup [webserver domain name] 192.168.0.1
> 
> on a device that is connected via the VPN?

This is where I took one or two steps forward.  Below is the console output 
during a VPN session.  I've interspersed a few comments:

terry@OptiPlex:~/Useful$ systemd-resolve --status 
Global 
  Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported 
resolv.conf mode: foreign 

Link 2 (eno1) 
   Current Scopes: DNS 
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/
unsupported 
Current DNS Server: 192.168.1.1 
  DNS Servers: 192.168.1.1

This is the response immediately after I've connected from the client (my 
desktop machine).  The client only knows about my local router which provides 
the DNS Service for machines logging on to my home network.

I then logged on to VPN Server (I've obfuscated the username for security 
purposes because this is a public forum):

terry@OptiPlex:~/Useful$ ssh @192.168.0.30 
@192.168.0.30's password:  
Linux VPN-Server 5.15.32-v7l+ #1538 SMP Thu Mar 31 19:39:41 BST 2022 armv7l 

I then tried to run 'systemd-resolve --status' but this isn't supported so I 
did: