@PING or @IPADDRESS for hosts with only IPv6 addresses

MPB

Mar 3, 2016
17
0
50
I sometimes use a quick FOR loop on a list of machines to see which respond to pings, as a quick "up or down" status for me.

Some systems will only have IPv6 addresses in our internal DNS and I noticed that those fail to resolve at all with either @PING or @IPADDRESS. I can use the ping and nslookup commands just fine with the hostnames, and I can use @PING with the actual IPv6 address and that works, so it just seems to be the name resolution giving an error if all the DNS server returns are IPv6 and no IPv4.

Is that by design? Or should it in fact work and this is a bug? Or is it just me somehow. :)

For now I'm working around it with a bit of an ugly "if %@exec[ping -n 1 -w 1000 %hostname% > nul] EQ 0 then (echo %hostname% is UP) else (echo %hostname% is DOWN)" since the ping command returns zero if it could ping and 1 if it couldn't. But I do like how the @PING returns the ping time in milliseconds since it helps me know if this is a remote user, local, indicates which building or city they may be in, etc.

I considered using the APING plugin but it doesn't seem to have a function like @PING I could use. Which makes sense, because @PING should work. I guess I could use aping's feature to return the ipv6 address (since @ipaddress fails in this case) and then @PING that instead of the hostname, but... sigh... too much work for something that I really only use as a quick one-liner.
 

rconn

Administrator
Staff member
May 14, 2008
11,910
133
The problem is that if you pass a name, @PING doesn't know whether it's IPv4 or IPv6. It needs to set a couple of flags for the (third-party) library to force IPv6. @PING will do that if the name contains a ':' (IPv6 only); otherwise it defaults to IPv4.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,201
72
Albuquerque, NM
prospero.unm.edu
I considered using the APING plugin but it doesn't seem to have a function like @PING I could use. Which makes sense, because @PING should work. I guess I could use aping's feature to return the ipv6 address (since @ipaddress fails in this case) and then @PING that instead of the hostname, but... sigh... too much work for something that I really only use as a quick one-liner.
MBP: Would you mind verifying that @LOOKUPHOST works for your situation?

I could probably add a function along the lines of @PING, if it would add some useful functionality versus the built-in function.
 

MPB

Mar 3, 2016
17
0
50
I don't know about a @LOOKUPHOST function, but here's a way to test it out.
(EDIT: I presume that's a function in the APING plugin... I haven't actually tried it out yet, but I'll definitely give it a go)

Google operates an IPv6 test site that only has an IPv6 address. "ipv6.google.com"

I can "nslookup ipv6.google.com" and "ping ipv6.google.com" okay, but these TCC commands give errors:
Code:
C:> echo %@ipaddress[ipv6.google.com]
11004

C:> echo %@ping[ipv6.google.com]
-3
That should give you an idea of what I'm looking at. In the environment I'm in, the situation I have is that sometimes a client is connected to the network over DirectAccess which is an IPv6-only connection, so when I do a quick little "if %@ping[%host%] GE 0" it fails on those, even though I can actually ping them via their IPv6 address.

I'm working around it, but I looked back at the release notes for the past however many versions (I'm using TCC v23) and I think I saw that IPv6 was added to the ipworks DLL's quite a while back, like v17 or v18? I'd just never had a reason or opportunity to try it on these functions before.
 
May 20, 2008
10,564
78
Syracuse, NY, USA
I can't either nslookup or ping ipv6.google.com. The DNS request times out.
Hmmm! Looking it up should work ... don't you think?

Code:
v:\> nslookup ipv6.google.com
Server:  Fios_Quantum_Gateway.fios-router.home
Address:  192.168.1.1

Non-authoritative answer:
Name:    ipv6.l.google.com
Address:  2607:f8b0:4006:819::200e
Aliases:  ipv6.google.com
Try it this way:

Code:
v:\> nslookup ipv6.google.com dns.google.com
Server:  dns.google
Address:  8.8.8.8

Non-authoritative answer:
Name:    ipv6.l.google.com
Address:  2607:f8b0:4004:800::200e
Aliases:  ipv6.google.com
 

MPB

Mar 3, 2016
17
0
50
That's odd. Does your system have IPv6 enabled? I'd have to dig up a system that has it turned off so I can test that. Maybe if ipv6 is disabled on the adapter, Windows won't show that result (since it wouldn't work anyway).
...
No, that wasn't it. I disabled ipv6 on a test machine and it was still able to resolve the ipv6 address okay (not totally scientific, but I did ensure the ipv6 link local address disappeared, and I didn't have any other 6to4 technologies enabled).

Maybe it's the DNS server you're pointing to? You could try Google's own, or the 1.1.1.1 server:
nslookup ipv6.google.com 8.8.8.8
or
nslookup ipv6.google.com 1.1.1.1

Just to rule out any local resolver issues. If you had a Linux box I'd suggest trying "dig" but I'm not sure what the best way would be on Windows, to make sure the local resolver is okay and/or see what types of responses are coming back.
 

MPB

Mar 3, 2016
17
0
50
FYI, I installed the APING plugin and tried this, which works. It's a bit awkward but it gets me what I was trying to do in the first place:
Code:
echo %@ping[%@lookuphost[ipv6.google.com]]
Since the native @PING function actually does work with ipv6 address but not via a hostname that resolves to an IPv6 address, it's just a workaround to give it the IP address directly. Like I said, kind of hacky, but it works. :smile:

Hopefully the native @IPADDRESS and @PING features can be set to work okay for cases where ipv6 is the only address returned, in some future version.
 
Aug 23, 2010
581
7
DNS lookups are not related to having IPv6 enabled or not.
I don't have IPv6 enabled, but

nslookup -type=AAAA ipv6.google.com.

yields:

Code:
Non-authoritative answer:
ipv6.google.com canonical name = ipv6.l.google.com.
ipv6.l.google.com       has AAAA address 2a00:1450:4010:c07::71
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,201
72
Albuquerque, NM
prospero.unm.edu
FYI, I installed the APING plugin and tried this, which works. It's a bit awkward but it gets me what I was trying to do in the first place:
Code:
echo %@ping[%@lookuphost[ipv6.google.com]]
I'm uploading a new version of APing: http://prospero.unm.edu/plugins/aping.html

This one includes a function @PINGTIME which works much like @PING, but will hopefully resolve IPv6-only hostnames. Let me know if it works for you.
 

MPB

Mar 3, 2016
17
0
50
Thanks, I'll check that out now that I have a little time again to poke at it. FYI, you may not have seen my reply to the other thread that was more APING specific, since it was kind of an old thread I accidentally zombified:

I mentioned that the plugin is fine on my Win10 machine, but on a server OS it gives a MIDI handle error. I only tried it on a Server 2012 R2 box (it has the GUI but probably doesn't have any audio devices if that helps).
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,201
72
Albuquerque, NM
prospero.unm.edu
Thanks, I'll check that out now that I have a little time again to poke at it. FYI, you may not have seen my reply to the other thread that was more APING specific, since it was kind of an old thread I accidentally zombified:

I mentioned that the plugin is fine on my Win10 machine, but on a server OS it gives a MIDI handle error. I only tried it on a Server 2012 R2 box (it has the GUI but probably doesn't have any audio devices if that helps).
Yeah, that's deliberate. If it can't start MIDI, the plugin won't load. (That's how it makes the sounds.)
 

MPB

Mar 3, 2016
17
0
50
Ah, I figured that was probably the case. I sometimes have to run some script on a system with access to a network that my workstation doesn't have (security reasons) and it's a VM - no audio device.

Oh well ... I won't be a pest and ask for a change just for me. :) But if you happened to think of it at some point... it's a nice plugin and being able to run it on a VM without an audio device would be snazzy. :)
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,201
72
Albuquerque, NM
prospero.unm.edu
Okay, I've uploaded a new build. If you define an environment variable NOMIDI before loading the plugin, then it won't try to use MIDI. The plugin will load, but you won't get any sounds.

If you don't define a NOMIDI variable and it can't open a handle to a MIDI device, the behavior is as before: you get an error message and the plugin fails to load.
 

MPB

Mar 3, 2016
17
0
50
Cool, I just gave that a try on a virtual machine without a sound card and it's working nicely. The plugin functions are much better than the hacky workaround I was doing by parsing the output of the ping command. It resolved an ipv6 only host as expected and the @pingtime worked great as well. I appreciate the quick update you made to get that working for me.