Is there a way I could block a specific network port connection for a specific app in Android? My phone is rooted. I know iptables -I OUTPUT -p tcp --dport xx -j DROP but this blocks those ports for every app. I want to block it for a single app.

  • This question is not specifically related to Android, better search related tags on superuser. – Irfan Latif Apr 1 '19 at 10:48

You can block all TCP traffic from app with UID 10142, destined for port 53:

~# iptables -I OUTPUT -m owner --uid-owner 10142 -p tcp --dport 53 -j DROP

Change UID and port as per your needs.

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.