I have two programs both of which are in Java.
Program A was written by me. If it wants to establish an external connection, I'm okay with this.
Program B was not written by me. If it wants to establish an external connection, I'm not okay with this.
How can I configure iptables to allow java A
to make outgoing connections, but java B
to be denied?
If iptables can't be used for this, what other options do I have?
If you run the programs as different users you can use the
owner
module.You must block the port that the program you don't want external access uses. Suppose it uses port 30000:
This is a simple rule, you can learn more on this simple howto. Depending on what distribution you use, you can also try AppArmor, a kernel level application firewall.