What middleware are you using? If it’s an option, you may want to consider switching to rmw_zenoh, which by default only works on localhost. This should make your system robust to the network dropping.
We have had the best results compiling rmw_zenoh from source as we found the release builds had a few issues.
Alternatively, try the “Improves Dynamic Discovery” configuration as linked to in the first reply here: Proposal : Restrict DDS to localhost by default (direct link is here - Improved Dynamic Discovery — ROS 2 Documentation: Rolling documentation)