You cannot do a firewall in java. java is not kernel level, therefore
you would need to open up and bind to every available port number before
you can read it.
You would be better off doing a linux module that is a firewall, such as
IPTables, or similar.