gtoal
Posts: 106
Joined: Sun Nov 18, 2012 12:02 am

How to access existing local wlan subnet on pi router?

Thu Jun 13, 2019 4:33 am

I also have several pies on my in-house network, acting as bridging wireless access points. (different SSIDs but they all bridge to the same 192.168.1 subnet, and that works great.) The majority of machines in my house (about 80 of them) connect via these pi-based access points.

Now for obscure reasons that are not worth explaining here, I have a second internal wifi network on 10.0.0 that has a few other machines on it. This subnet is behind a commercial NAT wifi router, so these addresses are not visible to the rest of the in-house net which is on 192.168.1 (although the in-house net is visible to the machines on 10.0.0 indirectly, through their nat gateway which connects to 192.168.1.1 by wire)

I would like machines on 192.168.1 to be able to *route* through to 10.0.0 via the main router 192.168.1.1

This should be fairly easy. Just have 192.168.1.1 attach *as a client* to the 10.0.0 wifi router. Then it will be able to forward packets to any 10.0.0 address, since routing is already enabled on it (being after all configured as a router)

The problem is that if I connect to a wifi network from the pi router, it thinks that the new network leads to the internet and changes its default route to the 10.0.0.1 access point. Which I don't want. I just want to access stations on 10.0.0 but not to route through that network to the internet.

So my question is "How do I make my 192.168.1.1 router log on as a client to the 10.0.0 wifi access point, without changing its default route to the 10.0.0.1 gateway which that access point advertises?"

I hope that was clear. To forestall inappropriate answers, I *don't* want to set this machine up as an access point itself (eg with hostapd), nor do I want to set up bridging to that subnet. I just want it to pick up a 10.0.0.x IP on wlan0 as a client and forward packets internally between eth1 (192.168.1) and wlan0 (10.0.0). I can set up a static route on 10.0.0.1 to direct packets for 192.168.1 back to the new wlan0 IP on my pi router which I'll make sure is a fixed address.

I can probably do what I want manually when I connect to the wifi, if I then do a 'route delete default' to get rid of the unwanted 10.0.0.1 gateway, followed by a 'route add default' to restore the original default route, but I don't want to do that manually and I'm not confident that it would be robust enough if done with wlan0's ifup/ifdown scripts - I don't want to take the chance of having the external internet connection go down just because I connected or disconnected to that private wifi subnet. It would be much more robust if bringing up the wifi never touched the default route to begin with.

Is there a recommended configuration? Something in wpa_supplicant.conf? I'm hoping the answer is a lot shorter than the question :-)

thanks,

G

epoch1970
Posts: 3049
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to access existing local wlan subnet on pi router?

Thu Jun 13, 2019 7:21 am

gtoal wrote:
Thu Jun 13, 2019 4:33 am
So my question is "How do I make my 192.168.1.1 router log on as a client to the 10.0.0 wifi access point, without changing its default route to the 10.0.0.1 gateway which that access point advertises?"
I can see 3 common ways to do this. Say the Pi's STA interface to the 10.0.0.x AP is wlan1.
  1. Have the DHCP server send no default route to that specific host. Linux-based DHCP servers should be able to do that, e.g. in dnsmasq

    Code: Select all

    dhcp-host=b8:27:eb:01:02:03,set:specialpi
    ...
    dhcp-option=tag:specialpi,option:router
    (that is an empty option 3, meaning "don't send it" to dnsmasq)
  2. Specify a lower metric to routes via wlan1 so that a default route will be setup but won't be used, e.g. in dhcpcd.conf

    Code: Select all

    interface wlan1
    metric 50
    ...
  3. Alter the routes set by the DHCP client via its default scripts by adding/changing scripts so that the redundant default route via 10.0.0.1 is immediately deleted, e.g. in dhcpcd via an exit-hook script.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

gtoal
Posts: 106
Joined: Sun Nov 18, 2012 12:02 am

Re: How to access existing local wlan subnet on pi router?

Thu Jun 13, 2019 9:33 am

(1) isn't an option with the specific AP in question. (3) is something I'ld rather avoid for reasons already given. (2) might work... I will give it a try and see if there are no unforseen problems.

Thanks. Still open to suggestions if anyone has any alternative methods.

G

epoch1970
Posts: 3049
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to access existing local wlan subnet on pi router?

Thu Jun 13, 2019 11:02 am

gtoal wrote:
Thu Jun 13, 2019 9:33 am
(1) isn't an option with the specific AP in question. (3) is something I'ld rather avoid for reasons already given.
Look at the code DHCP clients actually run. Almost everything is scripted...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

gtoal
Posts: 106
Joined: Sun Nov 18, 2012 12:02 am

Re: How to access existing local wlan subnet on pi router?

Thu Jun 13, 2019 3:59 pm

Thanks! Option #2 worked, I'm able to route through to the private subnet.

(It's actually a little more complicated than I hoped - I forgot that the *WAN* address of the proprietary wifi was also on the 192.168.1 subnet so the wifi unit will not advertise the static route via my client IP to that same net. However if I manually add the route that would have been advertised, to clients within the 10.0.0 subnet, routing does actually work. Since I can get by with this workaround and I don't have the option of replacing this proprietary wifi AP with a pi, I can live with this limitation. Anyway, questions about setting up RIP on a Netgear device are beyond the scope of this forum, so I'll say thanks here and close this thread.)

Graham

Return to “Networking and servers”