ping: Lacking privilege for raw socket

I installed ping/inetutils via Homebrew inetutils on macOS 11.1 (20C69) Darwin 20.2.0 but can't use ping even as root:

$ sudo ping 8.8.8.8
ping: Lacking privilege for raw socket.

Setting S bit didn't help

$ ls -l `which ping`
lrwxr-xr-x  1 denys  staff  15 Jun 10  2015 /usr/local/opt/inetutils/libexec/gnubin/ping -> ../../bin/gping
$ sudo chmod u+s /usr/local/opt/inetutils/bin/gping
$ sudo chmod u+s /usr/local/bin/ping

Most likely the owner of gping is not root so setting the S bit alone won't help. You need to change the owner to root first and set the S bit afterwards, you also need to make sure to change that on the actual binary not on any symlinks pointing to it.

$ gping 8.8.8.8
ping: Lacking privilege for raw socket.
$ ls -l /opt/homebrew/Cellar/inetutils/*/bin/gping
-rwxr-xr-x  1 verence  staff  113824 Jan 25 14:29 /opt/homebrew/Cellar/inetutils/1.9.4_2/bin/gping
$ sudo chown root /opt/homebrew/Cellar/inetutils/*/bin/gping
$ sudo chmod +s /opt/homebrew/Cellar/inetutils/*/bin/gping
$ ls -l /opt/homebrew/Cellar/inetutils/*/bin/gping
-rwsr-sr-x  1 root  staff  113824 Jan 25 14:29 /opt/homebrew/Cellar/inetutils/1.9.4_2/bin/gping
$ gping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=112 time=1.423 ms
^C

PS: /opt/homebrew is the default installation directory for Homebrew on M1 Macs, use /usr/local instead for Intel Macs.