I’ve seen this page by RTI which might be useful: Statically configure a Firewall to let OMG DDS Traffic through | Data Distribution Service (DDS) Community RTI Connext Users
It has a spreadsheet for calculating the ports used by RTI Connext (one of the supported ROS 2 middleware implementations) which might also apply to other vendors. I haven’t used it myself.
Morgan mentioned the domain ID - note that the participant ID that’s used in these equations isn’t currently exposed/set by ROS 2, but it may be set by vendor-specific config files.