0

How can I disable internet but keep the network access on Android tablet? I want to be disable internet access to all but selected apps, at the same time I want applications to have direct internal network access.

I used firewall in the past but firewall disables access to all networks. I want to be able to use my tablet in my home, at the same time I want to disable internet access on it.

Is it possible? What is the best way to do create this kind of limitation for the apps?

thanks

  • 2
    Disable routing of your tablet in your gateway. – roxan Jul 13 '13 at 4:57
0

On the router

As roxan already wrote, this cannot be done on the Android device itself (well, at least not easily), but should take place at your router. Some routers allow to specify on a per-device basis whether internet access should be granted, using a single "switch" (yes/no).

If that's not possible, you'd need to edit firewall rules. This would require to assign a fixed IP to your device, so on your router you could specify e.g. (pseudo-code):

route from <android_ip> to <internal_network> pass
route from <android_ip> to * reject/drop

(again, that's pseudo-code; I'm not that familiar with iptables to give the exact syntax by heart). What that then would do: All packages from your Android device would pass the router if targeted to the internal network, but would be rejected (visible to the Android device, so it could react immediately) or dropped (connections would timeout then) when targeted to the outside.

Basically, as Android uses iptables as well, the same should be possible directly on the device, one might think. But I'm not sure whether that is really true: from the Android device's point of view, everything is targeted outside (to its gateway). Which gives another idea:


On the Android device

I've just checked on my device, and Android indeed includes the route command (though I needed to run it via busybox, e.g. busybox route to show configured routes). So let's assume your local network uses 192.168.0.*, and your router being 192.168.0.1, you could do the following:

# default gateway (should already be defined), but we don't want this
#route add default gw 192.168.0.1 wlan0
route del default gw wlan0
# re-add route for access to the local network
route add -net 192.168.0.0 netmask 255.255.255.0 192.168.0.1 wlan0

Now the device should no longer know what to do with packages e.g. for 8.8.8.8, and would return a "no route to host". The example already shows a problem involved: 8.8.8.8 is one of the pre-configured name servers. So make sure you configure your device to use a name server in your local network, if you want name resolution (well, Google's name server won't be of much use for your internal network either).

Not also that your interface used might not be called wlan0. Find out by invoking route without any arguments: this will list all established routes like this:

link-local      *               255.255.0.0     U     1000   0        0 eth0

So in this case, I had to use eth0 for the interface.

192.168.0.0     *               255.255.255.0   U     205    0        0 wlan0

This would describe our example, using wlan0 as interface, and 192.168.0.* as network. As on my device this route already had been present in the routing table, it might even suffice to simply drop the default gateway.

I didn't run a test to verify everything is fully working according to your intention (though it should, I might have included some typo here or there). So I'd be glad to hear from you how well it did :)

  • Izzy, thanks for super detailed answer. Well explained. The issue is this though, is adding the route one time for next boot? – yarun can Jul 13 '13 at 15:46
  • No, you would need to repeat that after a boot. Or you would need to modify the boot image accordingly, which is not really feasible. Much better would be using Tasker, and have a script executed after each boot, if you need it "more permanent". – Izzy Jul 13 '13 at 20:50
0

Droidwall an app will be the perfect answer to that. (ATTENTION: will require root).

  • No, that won't help here. See the question once more, please: I used firewall in the past but firewall disables access to all networks. – Izzy Jul 13 '13 at 9:47
  • Izzy thanks for the point. It is true that firewalls are big brush in Android so it is not a use to me on the tablet as far as I can tell. – yarun can Jul 13 '13 at 15:40
  • @Izzy I am using the Droidwall on my N4 with stock but rooted phone and i can block whatever I want to, and can still use the app. Still you need something advanced like making an app behave as if internet is on but actually it is not then you can use the "Exposed Framework" (hope you are aware of it). The Droidwall I mentioned used IP table rules to mod the app accordingly and I am satisfactorily using it. – Tirath Jul 15 '13 at 6:42
  • To my knowledge, Droidwall either blocks network access completely for the app, or not at all (yes, per-app and yes, per interface). Are you saying it's easy to use for selective blocking (i.e. "app is allowed to access 192.168.0.*, but nothing else")? Because that's what yarun wants. – Izzy Jul 15 '13 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.