It's possible that ROS2 is not allowing you to switch between WiFi and 5G networks because of the way that ROS2 is managing its network connections. ROS2 uses DDS (Data Distribution Service) for communication between nodes, and DDS typically relies on multicast for network discovery and communication.

When you switch networks, the multicast traffic can get lost or blocked, which can disrupt the DDS communication between nodes. This can cause ROS2 to become unresponsive or lose its connections to other nodes.

To avoid these issues, it's recommended that you stop the ROS2 nodes before switching networks, and then restart them once you've switched to the new network. This will allow ROS2 to re-establish its network connections and continue functioning properly.

Quick Fix (Tested)

The only thing that resolved this for me (at least temporarily) was to stop the ros2 daemon and restart it on each system:

ros2 daemon stop

ros2 daemon start