1

I have an app, a replica of a shooter game in Android. It is just for experimental use only, me and my friends are testing it. I need to block all TCP connections so I can test my security.

But its servers change IP addresses of the domain, so no matter how many ways I use to block the domain, user still get connection with the server.

Is there a way to only block TCP connection for an app? But only TCP connection, because my playing server is UDP server.

Can I block all incoming TCP connections as well?

0

1 Answer 1

0

Is there a way to only block TCP connections for an app in Android?

Yes, if you have rooted phone:

~# iptables -I OUTPUT -m owner --uid-owner 10275 -p tcp -j DROP

This will block 100% outgoing TCP traffic of app having uid 10275. You can get UID from file /data/system/packages.list.

To block only UDP:

~# iptables -I OUTPUT -m owner --uid-owner 10275 -p udp -j DROP

Or to block both, don't mention any protocol.

Can I block all incoming tcp connections?

INPUT doesn't work with owner module. Better is to just block outbound traffic, incoming is automatically blocked because traffic is initiated from client end i.e. your phone.
See this answer for details.

Also you can use iptables based firewall app like AFWall+ or VPN based firewall like Netguard to block outbound traffic.

1
  • Thank you this worked perfectly Commented Mar 31, 2019 at 16:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .