traviscross / mtr

Official repository for mtr, a network diagnostic tool
http://www.bitwizard.nl/mtr/
GNU General Public License v2.0
2.64k stars 337 forks source link

MTR -a and dest hostname resolving one IPv6 #510

Open paulofragoso opened 1 month ago

paulofragoso commented 1 month ago

Hi Folks,

When I'm using mtg with -a and IPv4 to reach host name like meet.google.com it's reporting:

mtr: invalid local address

because destination are using IPv6 from gethostbyname. Is possible change to more clear error and suggest to use -4? Or to use IPv4 from gethostbyname when using -a with IPv4?

Thanks, Paulo.

yvs2014 commented 1 month ago

mtr(8) reads:

      -a ADDRESS, --address ADDRESS
              Use this option to bind the outgoing socket to ADDRESS, so that all packets will be sent with ADDRESS as source address.

if you with mtr are not being on the meet.google.com, then '-a meet.google.com' is terminated with totally correct 'invalid local address' message.

rewolff commented 1 month ago

@yvs2014 I think @paulofragoso is doing -a <somelocaladdress> meet.google.com And that local address might be IPV4 which doesn't work if your kernel is IPV6 enabled. So he got a confusing message instead of something explaining the situation.

@paulofragoso : I am opposed to "guessing the cause of the error messages". A long time ago the DOS (3.11 I think. or was it 6.x?) command "rmdir" would "know" that if the OS gave an error, it MUST be that the directory didn't exist to begin with. So when you tried rmdir on a network drive, you'd get: "rmdir: directory doesn't exist", when you could clearly see the directory. Turns out it was a "permission denied" error and rmdir was written when that wasn't one of the possible return codes for the system call...

So MTR reports what the OS tells us. If we implement a special case for this situation and end up getting this error later with a different cause, it is going to cause even bigger confusion.

IMHO the "invalid local address" is 100% correct. You've provided an incorrect local address for what you're asking mtr to do.

paulofragoso commented 1 month ago

@rewolff is exactly this and I agree that all is correct but I think that one check between -a and dest_host_name are in same stack (IPv4 or IPv6) will help network operators in hot time, because use host name for destination is common.

Many Thanks for attention!