Short version: How do I allow the Yast Firewall on a Linux server to allow sockets to connect with a randomly (by os) selected port?
Longer version: A part of my larger java program has a client connecting to server using sockets. The initial connection is done at a specific port with a ConnectionManager, that gives the client a port and password to connect to. The way I originally pick the port was through a list of ports (all above 49152) that I allowed in the firewall. I noticed that this new connection would randomly work, or refuse to connect. I concluded that the ports where being closed or used by something else (tried to turn the firewall off, didn't help).
Then it was suggested that I let the os pick the port by not specifying the port number (using 0 as per this constructor: JavaDoc). This picked a free port, that works perfectly when the firewall is down. However, the firewall blocks the connection, and the client times out.
Is there anyway to set up the Yast firewall to allow the sockets, without overexposing the server? Or can/should I specify a range of port numbers for java to pick an open one, and allow those ports?
NOTE: I originally asked this on stackoverflow and was suggested to post here. It exactly the same there: StackQuestion.