How can I block incoming connections? I've been looking for a firewall app for Android for a couple hours now and all I could find is apps that only let me block outgoing connections (for specific apps). Is there any way to set which incoming connections and on which ports should be allowed/denied (something like Inbound Rules in Windows Firewall)? I'm OK with with the app requiring root.
If you don't mind with the solution not being an app, then you can use iptables. They are included in the AOSP kernel. You can access them by downloading a terminal app off of the app store. You might however need root for this.

The usage of iptables on android should be same as the ones on desktop Linux, so you can look up some GNU manual for it.