ping.go example hangs forever but I see ICMP requests and replies:
$ ./ping -c 5 www.yandex.ru
PING www.yandex.ru (77.88.55.80):
^C
--- www.yandex.ru ping statistics ---
5 packets transmitted, 0 packets received, 0 duplicates, 100% packet loss
round-trip min/avg/max/stddev = 0s/0s/0s/0s
tcpdump output 5 requests and replies:
15:10:34.417077 IP 192.168.0.3 > 77.88.55.80: ICMP echo request, id 29, seq 0, length 24
15:10:34.423019 IP 77.88.55.80 > 192.168.0.3: ICMP echo reply, id 29, seq 0, length 24
....
$ getcap ./ping
./ping = cap_net_raw+ep
$ sysctl net.ipv4.ping_group_range
net.ipv4.ping_group_range = 0 2147483647
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ go version
go version go1.15.8 linux/amd64
Should it send UDP packets instead of ICMP in unprivileged mode?
It works in privileged mode as expected:
$ ./ping --privileged www.yandex.ru
PING www.yandex.ru (5.255.255.5):
24 bytes from 5.255.255.5: icmp_seq=0 time=8.114374ms ttl=55
24 bytes from 5.255.255.5: icmp_seq=1 time=8.309559ms ttl=55
ping.go example hangs forever but I see ICMP requests and replies: $ ./ping -c 5 www.yandex.ru PING www.yandex.ru (77.88.55.80): ^C --- www.yandex.ru ping statistics --- 5 packets transmitted, 0 packets received, 0 duplicates, 100% packet loss round-trip min/avg/max/stddev = 0s/0s/0s/0s
tcpdump output 5 requests and replies: 15:10:34.417077 IP 192.168.0.3 > 77.88.55.80: ICMP echo request, id 29, seq 0, length 24 15:10:34.423019 IP 77.88.55.80 > 192.168.0.3: ICMP echo reply, id 29, seq 0, length 24 ....
$ getcap ./ping ./ping = cap_net_raw+ep $ sysctl net.ipv4.ping_group_range net.ipv4.ping_group_range = 0 2147483647 $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal $ go version go version go1.15.8 linux/amd64
Should it send UDP packets instead of ICMP in unprivileged mode? It works in privileged mode as expected: $ ./ping --privileged www.yandex.ru PING www.yandex.ru (5.255.255.5): 24 bytes from 5.255.255.5: icmp_seq=0 time=8.114374ms ttl=55 24 bytes from 5.255.255.5: icmp_seq=1 time=8.309559ms ttl=55
Any ideas please?