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

Unknown Object (User) changed the task status from Open to Confirmed.May 13 2020, 9:24 PM
Unknown Object (User) added a subscriber: Unknown Object (User).

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

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.

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

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

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

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