Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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.
iptables -I OUTPUT -p tcp --dport xx -j DROP
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.
Required, but never shown