My notepad

Chris' IT notes…
← Back

Ping requires sudo on WSL?

Annoyed that you have to use sudo to run a simple ping command? Well, the fix is easier then expected :-) Let's do a quick check. Run this:

sh
getcap $(which ping)

If it returns nothing the following command will mostly likely fix it.

That means the binary has no capabilities. On modern Debian/Ubuntu, ping is not setuid anymore. It relies on cap_net_raw=ep Since sudo ping works, this is almost certainly the only problem.

To fix, run now:

sh
sudo apt install --reinstall iputils-ping libcap2-bin
sudo setcap cap_net_raw=ep /usr/bin/ping

The first line is mostly redundant, but safer to run, just to be sure. The second one, is the one that does the magic ;) And if you check again getcap $(which ping) you should see now /usr/bin/ping cap_net_raw=ep

Now... try again your ping.

...and you're welcome! ;-)