Skip to content

Instantly share code, notes, and snippets.

@mzpqnxow
Last active March 10, 2026 21:21
Show Gist options
  • Select an option

  • Save mzpqnxow/ff88b5a519f5c3303ef8bc9de0245179 to your computer and use it in GitHub Desktop.

Select an option

Save mzpqnxow/ff88b5a519f5c3303ef8bc9de0245179 to your computer and use it in GitHub Desktop.
Disable MDNS in Chrome via Chrome policies on the commandline
#!/bin/bash
#
# Disable mDNS for Chrome, Chromium and Brave
# Used on Debian 13
#
# Confirm it works:
# $ lsof -n -i -P | grep -F '224.'
#
# You can/should also just disable multicast on your interfaces if you don't need it
# $ sudo ifconfig $iface -multicast
#
# @mzpqnxow
# Updated 2026
#
set -euo pipefail
config_blob='{ "EnableMediaRouter": false }'
bases=(
/etc/opt/chrome
/etc/brave
/etc/chromium
)
for base in "${bases[@]}"; do
file="$base/policies/managed/disable_mdns.json"
if [[ -f $file ]]; then
echo "Skipping $file (already exists) with the following content:"
echo "=== $file ==="
echo
cat "$file"
echo
echo
continue
fi
echo "Setting $file"
printf '%s\n' "$config_blob" |
sudo install -Dm644 /dev/stdin "$file"
done
@davehayes
Copy link
Copy Markdown

Did you check after an hour or two of usage? I'm finding that the mDNS listening comes back after an hour.

@varenc
Copy link
Copy Markdown

varenc commented Aug 19, 2020

Thanks! I can confirm this seems to have realllly slows down Chrome's spam. (For anyone else on macOS, you need to make a .mobileconfig profile to flip EnableMediaRouter to false.)

@varenc
Copy link
Copy Markdown

varenc commented Aug 20, 2020

actually, now I'm seeing the same thing @davehayes is. Eventually Chrome goes back to mDNS listening and resolving every ._googcast._tcp.local. service every time one is announced... If you have a lot of Chromecasts and GHome on your network then that means your Chrome will be constantly busy. (GDevices are spammy and their mDNS broadcast traffic rates grows O(n^2) where n is the number of GDevices)

@neoavalon
Copy link
Copy Markdown

The #enable-webrtc-hide-local-ips-with-mdns flag no longer showed up for me on chrome 87.0.4280.88. Enabling the flag #temporary-unexpire-flags-m85 showed this flag again but after finally setting #enable-webrtc-hide-local-ips-with-mdns to Disabled, the mDNS entries reappeared again after a while as others mentioned.

@mzpqnxow
Copy link
Copy Markdown
Author

You can try setting the immutable flag on the configuration file after you modify it. You’ll need elevated privileges to do so, though

The simplest way to do a basic test would be to shut down all chrome instances, make the change, then sudo chattr +i . Until you chattr -i the file, it won’t be mutable by any users (not even root)

The file has to be on an ext-based file system because it uses the extfs extended attributes

You could also try just chowning it to root, but it’s possible it could be deleted and recreated as a normal user since the directory will be owned by a normal user

good luck, let me know if you figure anything out. I stopped using Chrome entirely a while ago so haven’t looked at it all on probably over a year

@mzpqnxow
Copy link
Copy Markdown
Author

BTW- there are probably extensions that can disable the mDNS- but a pure configuration change is so much better than adding more code to your system- even if it is (mostly) sandboxed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment