mDNS flood

Over the last two days I have had my homeassistant installation generate a flood of mDNS requests which had crippled my wifi. I was wondering if others have seen the same issue.

It took me a while to realise that the wifi was slow because of an mDNS flood which was exacerbated by a mdns repeater on my router. On investigating further, it appears to be because my hass io install has been continuously sending mdns requests.
I was able to block these by running the following command in the terminal on the hass io install
iptables -A OUTPUT -p udp --dport=5355 -j DROP

This has resulted in the following error in the log file.

2020-08-31 17:24:16 WARNING (zeroconf-Engine-274) [zeroconf] Error sending through socket 14
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/zeroconf/__init__.py", line 2834, in send
    bytes_sent = s.sendto(packet, 0, (real_addr, port))
PermissionError: [Errno 1] Operation not permitted

But has solved the issue for now.

My setup:
HassOS 4.12 using Hass.io image on a raspberry pi 4
version: 0.114.4

I have the following add-ons installed:
File editor 5.0.0, Let’s Encrypt 4.10.0, Log Viewer 0.9.0, Mosquitto Broker 5.1 and SSH and Web terminal 7.5.0
Google Cast, Meteorologisk Institutt, Mobile App, MQTT, Philips Hue, Ring, Tuya and Zigbee Home Automation.
The problem may have started after the last update. I am not a 100 % sure about this. The issue was first seen late evening on 29th Aug and for the moment, I have blocked outgoing mdns packets using iptables.

Thanks for find this. I had been struggling with my network issues for a few months, trying to determine what was killing the wifi. In addition, it was also causing my router to spike at 100% CPU.

I have monitored WireShark and have noticed that HA floods with mDNS packets for some time and then stops.

In any case, I want to run the command you recommended, but before I do, i want to make sure I know how to undo it, in case I want auto discovery to run again.

Thanks

I haven’t had this problem for a while so haven’t used it since. I am not sure what fixed it.

To delete an iptables rule, you should be able to run
iptables -D OUTPUT -p udp --dport=5355 -j DROP
the
-D will delete the matching rule in the firewall.

You can see all the iptables rules with the command
iptables -L

The rules are not permanent and will be cleared on reboot. So that is always available as a last resort.

Thanks so much. I think for now I will monitor it an see what happens before I disable it completely.

So for anyone else looking up this problem. I hit the same problem again. This time it affected my printer. It was extremely sluggish and I couldn’t connect to it to print anything over the network. Looking at the network packets, there appeared to be the mdns flood as seen before and this had overwhelmed my printer. I was browsing through and found a bug which explains the problem.

There is a fix in the beta branch at the moment. I have applied the fix on my setup which seems to have fixed the issue I was seeing with the printer. The mdns storm has reduced and the printer is working fine again.