Page MenuHomeVyOS Platform

IPv6 ping by address not working
Closed, ResolvedPublicBUG

Description

$ ping speedtest.net
PING speedtest.net(2a04:4e42:600::731 (2a04:4e42:600::731)) 56 data bytes
64 bytes from 2a04:4e42:600::731 (2a04:4e42:600::731): icmp_seq=1 ttl=60 time=36.10 ms
64 bytes from 2a04:4e42:600::731 (2a04:4e42:600::731): icmp_seq=2 ttl=60 time=37.0 ms
64 bytes from 2a04:4e42:600::731 (2a04:4e42:600::731): icmp_seq=3 ttl=60 time=36.10 ms
64 bytes from 2a04:4e42:600::731 (2a04:4e42:600::731): icmp_seq=4 ttl=60 time=36.10 ms
$ ping 2a04:4e42:600::731
ping: Unknown host: 2a04:4e42:600::731

Details

Difficulty level
Normal (likely a few hours)
Version
1.3-rolling-202005122226
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)

Event Timeline

daniil created this task.Wed, May 13, 6:55 PM
Dmitry changed the task status from Open to Confirmed.Wed, May 13, 9:24 PM
Dmitry added a subscriber: Dmitry.

Issue with socket.gethostbyname()

gethostbyname() does not support IPv6 name resolution, and getaddrinfo() should be used instead for IPv4/v6 dual stack support.

https://github.com/vyos/vyatta-op/blob/current/scripts/ping#L211

jjakob added a subscriber: jjakob.Thu, May 14, 1:19 PM

Why not just use the OS's ping command? It does address resolution. Resolving a IP address as hostname would leak the IP via DNS as well.

pasik added a subscriber: pasik.Thu, May 14, 2:19 PM
diff --git a/src/op_mode/ping.py b/src/op_mode/ping.py
index 45b06aa9..f723933b 100644
--- a/src/op_mode/ping.py
+++ b/src/op_mode/ping.py
@@ -210,7 +210,7 @@ if __name__ == '__main__':
     try:
         ip = socket.gethostbyname(host)
     except socket.gaierror:
-        sys.exit(f'ping: Unknown host: {host}')
+        ip = host

     try:
         version = ipaddress.ip_address(ip).version
c-po added a subscriber: c-po.Sat, May 23, 6:13 PM

That patch is invalid as ping.py does not exist under vyos-1x package, its in vyatta-op.

Gonna take the opportunity and migrate this

c-po added a comment.Sat, May 23, 6:16 PM
In T2457#63617, @jjakob wrote:

Why not just use the OS's ping command? It does address resolution. Resolving a IP address as hostname would leak the IP via DNS as well.

Unfortunately it does not support VRFs

c-po closed this task as Resolved.Sat, May 23, 6:21 PM
vyos@vyos:~$ ping 2a04:4e42:600::731
PING 2a04:4e42:600::731(2a04:4e42:600::731) 56 data bytes
64 bytes from 2a04:4e42:600::731: icmp_seq=1 ttl=61 time=6.45 ms
64 bytes from 2a04:4e42:600::731: icmp_seq=2 ttl=61 time=6.53 ms