12

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?

Brett
  • 484
  • 6
  • 16
  • 1
    This is not really about programming... You might have more success if you post elsewhere. – Jonas Czech Mar 01 '15 at 14:36
  • 1
    But programmers are the people most likely to have had similar requirements, and as such are most likely to know what workarounds/obscure APIs/alternatives might be effective. – Brett Mar 02 '15 at 05:23
  • 2
    True... [This](http://stackoverflow.com/questions/18394066/android-use-wifi-direct-and-cellular-data-in-app) and [This](http://stackoverflow.com/questions/24429190/how-wifi-and-mobile-data-both-work-simultaneously-in-android-for-obd2-device) may help, although possibly only if you are doing the network requests in your own app which you have written yourself. (So you can use the appropriate APIs) – Jonas Czech Mar 02 '15 at 14:41
  • Updated the question to include that this is a problem within a total solution I'm developing, that includes (what I thought was obviously) a cross-platform custom mobile application :). – Brett Mar 04 '15 at 00:09
  • Any luck for Android? I am also looking for almost same scenario including Pi as access point for a specific service and wanting to download some data from mobile connection. – Chadwick Robbert Jul 03 '15 at 16:10
  • I am also looking for something like this as a way to tether. – ucipass Jun 07 '18 at 20:31
  • Any success with Android as of May 2019? – jjmontes May 09 '19 at 20:48

2 Answers2

1

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.

Kevin Keane
  • 1,506
  • 12
  • 24
  • Regarding the windows situation, good thought to put a DNS server on the pi. I have established a public dns entry for that private IP but it may be that the wifi connection isn't leveraging the public and available via the cell network. Hosts wouldn't help unless I could put a hosts file on every phone client - the phone needs the resolution so CORS will function. – Brett Mar 06 '15 at 20:04
  • I'm actually suspecting that Windows may simply block DNS responses with what it perceives as "invalid" IP addresses for security reasons. Also, putting a DNS server on the pi will not, by itself, help. In addition, you also have to have way to direct DNS queries *only* for that FQDN to the Pi, and all others to the public DNS server. Thus the need for another DNS server within the device. On the hosts: yes, I did mean to add your FQDN on each phone's host file. It may be trivial to do when installing your app, or it may be impossible. – Kevin Keane Mar 07 '15 at 07:54
  • Finally had time to test this. Installed pdns, configured duplicate zone for my publicly accessible zone, solved the problem for Windows Phone. Two down, one (Android) to go :). – Brett Mar 15 '15 at 03:38
0

For Android phone you can use application named "WiFi & Mobile Data Switch" (https://play.google.com/store/apps/details?id=com.totemsoft.wifimd). For me it solves the problem of simultaneous connecting to internet (via mobile data) and to local network (via WiFi, internet is inaccessible via WiFi). This applications works ok on Samsung Galaxy A8. I hope, my comment helps to somebody.

Kirill Frolov
  • 401
  • 4
  • 10