How to limit an app's access only to specific networks? I'm currently using DroidWall to limit apps' access to the Internet - and it's working great.

Recently I've started to have the need of allowing certain apps network connectivity, but limited only to the current LAN (e.g. only to communicate with IP addresses 192.168.1.x)

DroidWall doesn't seem to offer this in any trivial way (except, perhaps via its custom scripts, for which there aren't any clear instructions for how to apply them only to an individual app).

How can I limit an individual app to LAN access only?
You can use rules like this in your custom scripts:

$IPTABLES -A "droidwall-wifi" -m owner --uid-owner 12345 --destination "192.168.1.0/24" -j RETURN


Instead of 12345, you need to specify the UID assigned to the app; you can find that UID in the list of apps in DroidWall.

Remember that UIDs are assigned dynamically, and if the app is removed, the UID previously assigned to it may be assigned to a completely different app installed later.

There are some enhancement requests for DroidWall (#275, #253) requesting to add such feature, but developers did not respond to them yet.