Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing WiFi LAN (no gateway) and mobile network simultaneously

I'm aware it's been asked before (with limited or no solution) but I haven't seen any recent updates and I think my scenario is unique so I'll start a new thread.

I have a Raspberry Pi and it's functioning as a hot spot among other things. By design, DHCP isn't handing out a default gateway. My use case is one or more devices interacting with the Pi as a server.

One of the connected devices will be a mobile device(edit: running a custom app of my design which is part of the total solution), and that device will maintain its cellular connection, not for tethering or routing but so that the application can access internal and external resources simultaneously.

Currently:

IOS: This works exactly as I expect on IOS - it senses that the WiFi network doesn't have a default gateway and sends external traffic over cell.

Android: This doesn't work at all. Android stubbornly sees WiFi connected and disables cellular, even with no default gateway.

Windows Phone: Kind of a hybrid. Both networks stay up but my scenario has a DNS entry in public DNS, and a public site links to a resource on the Pi. If I link to the resource directly using the WiFi IP address of the Pi, it works fine (although this causes other issues related to security). If I link via a FQDN, I'm actually not sure what's going on. It doesn't resolve from the web browser although every networking utility I've installed on the phone for troubleshooting correctly resolves the FQDN to the Pi address via DNS.

Hope this makes sense. The question: How can I enable this functionality across the board in 2015? :) For my purposes, the Pi as a private nonroutable hotspot works better than WiFi direct or Bluetooth. And remember I'm not asking the phone to ROUTE; I need my custom application to be able to simultaneously connect to the Pi and to the public Internet. I want all the phones to do what IOS does in this regard.

My current scenario is the Pi hosting a web page (among other things) and that's my preference, but can this even be solved natively?

like image 210
Brett Avatar asked Feb 09 '15 05:02

Brett


People also ask

How can I use LAN and internet at the same time?

The Ethernet connection is called Local Area Connection and the wireless connection is called Wireless Network Connection. Click on Local Area Connection to select it. Press and hold the Ctrl key and click on Wireless Network Connection to select it. Now you should have both connections selected.

What happens when you connect to Wi-Fi and Ethernet at the same time?

Connecting to both Wi-Fi and ethernet at the same time can slow your internet speed because the data packets being sent by the router can get mixed up, duplicated, and/or received in the incorrect order on your computer. Your computer won't be able to process the information correctly and the internet will slow down.

Can you use LAN and WAN at the same time?

Fortunately, a device can be part of both a LAN and a WAN at the same time. Remember how we said that LAN devices have their own local IP address? This doesn't mean it can't get an internet IP address, too. In fact, if you're reading this article on a device connected to a router, it'll have both!


1 Answers

You say that this is not a tethering or routing situation, but if you think about it, it really is both.

It is routing because the traffic from the phone needs to be routed to one of the two interfaces. There may not be routing through the phone, but it's still a routing problem. Fortunately, it seems that the routing part is working on all three platforms.

It is also an unusual form of tethering. The only differences are that traffic does not originate from the Pi, but from the phone, and that the Pi rather than the phone acts as the access point.

Thinking of it in terms of tethering is important because it shows that the Android CAN have WiFi and cellular active at the same time (at least in hotspot mode, but probably also in client mode). In this respect, my answer isn't complete - I can't tell you HOW to accomplish that.

As for the Windows phone problem you mentioned: in order to troubleshoot that, first identify where the DNS server is located that knows about the Pi's FQDN. Does a public DNS server know about it, even though it is obviously on a private network?

There are two possible explanations for your observation:

  • There is no public DNS server that even knows this FQDN. In that case, IOS is probably using something like mDNS to locate the Raspberry Pi.
  • There is a public DNS server that knows this FQDN. In that case, maybe Windows Phone checks the DNS reply for martians and rejects it, thinking that it is an attack.

Either way, what you'd really need is to have two separate DNS infrastructures. One way to do this is to include a small DNS server (dnsmasq maybe) with your app, and configure a forwarder for the zone with the Pi's FQDN to forward to the Pi's IP address (which would have to be hardcoded, obviously). All other requests should go to the normal DNS servers.

Another way might be to not use DNS at all, but use the hosts file instead.

like image 145
Kevin Keane Avatar answered Nov 03 '22 00:11

Kevin Keane