Ping troubles with hostname

Greetings,
I am facing an unusual issue. When I ping via a local IP address it pings as it should, false if nothing is connected and a number greater than 0 if something is connected. However, when I ping using hostnames I get a response no matter what. For instance, if I ping "zone3" and zone3 is not connected to the network the ping still responds that something is connected.

Any ideas on how to resolve short of using the IP addresses?

PS C:\WINDOWS\system32> ping -a zone3
Ping request could not find host zone3. Please check the name and try again.
PS C:\WINDOWS\system32>

but back to NodeRED using the ping node

zone3 : msg.payload : number

64.7

Which ping node are you using? Check in Manage Palette. Are you using the latest version of it?

I just updated the node, its node-red-node-ping 0.3.0

I restarted node-red after the update. The problem still persists.

What else may I try?

Edit: its not a huge issue, but I would prefer if I am able to sucessfully use the hostname

Feed the output into a debug node set to show Complete Message and see if there is any other information in the message.

Here is the complete message of the payload:

3/30/2021, 1:06:17 PMnode: adf7f7a8.cc7ab8
zone3 : msg : Object
object
payload: 65.1
topic: "zone3"
_msgid: "bd1b1517.87a1e8"

Here is the output when inserting a non existant ip:

3/30/2021, 1:07:52 PMnode: adf7f7a8.cc7ab8
192.168.2.54 : msg : Object
object
payload: false
topic: "192.168.2.54"
_msgid: "a2a180ab.ff173"

Here is the message of an existant zone via hostname

3/30/2021, 1:09:17 PM[node: adf7f7a8.cc7ab8](http://192.168.1.73:1880/#)zone4 : msg : Object

object

payload: 0.258

topic: "zone4"

_msgid: "9b7fa005.72294"

You think I should check if its running too long as well as the false case?

If you put a random host name in what happens?

Can you show us how you have configured the ping node please. Also what version of node-red are you using and what version of nodejs? You can get those from the node-red startup log. In fact if you post the startup log that may be useful.

I am using Noderev v1.2.3 and node js v10.21.0

Starting as a systemd service.
30 Mar 21:00:16 - [info]
Welcome to Node-RED
===================
30 Mar 21:00:16 - [info] Node-RED version: v1.2.3
30 Mar 21:00:16 - [info] Node.js  version: v10.21.0
30 Mar 21:00:16 - [info] Linux 5.4.72-v7l+ arm LE
30 Mar 21:00:19 - [info] Loading palette nodes
30 Mar 21:00:24 - [info] +-----------------------------------------------------
30 Mar 21:00:24 - [info] | uibuilder initialised:
30 Mar 21:00:24 - [info] |   root folder: /home/pi/.node-red/uibuilder
30 Mar 21:00:24 - [info] |   version . .: 2.0.8
30 Mar 21:00:24 - [info] |   packages . : vue,bootstrap,bootstrap-vue,jquery,socket.io,ejs
30 Mar 21:00:24 - [info] +-----------------------------------------------------
30 Mar 21:00:24 - [info] Dashboard version 2.23.4 started at /ui
30 Mar 21:00:25 - [warn] ------------------------------------------------------
30 Mar 21:00:25 - [warn] [node-red-contrib-sacn-in/sacn_in] Error: Cannot find module 'e131' (line:2)
30 Mar 21:00:25 - [warn] ------------------------------------------------------
30 Mar 21:00:25 - [info] Settings file  : /home/pi/.node-red/settings.js
30 Mar 21:00:25 - [info] Context store  : 'default' [module=memory]
30 Mar 21:00:25 - [info] User directory : /home/pi/.node-red
30 Mar 21:00:25 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Mar 21:00:25 - [info] Flows file     : /home/pi/.node-red/flows_litserver.json
30 Mar 21:00:25 - [info] Server now running at http://127.0.0.1:1880/
30 Mar 21:00:25 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
30 Mar 21:00:25 - [info] Starting flows
30 Mar 21:00:26 - [info] Started flows
30 Mar 21:00:26 - [info] [sqlitedb:6b323ccf.99d464] opened /home/pi/.node-red/sqlite_database_01.db ok
30 Mar 21:00:26 - [info] [mqtt-broker:MQTT Server PI] Connected to broker: mqtt://localhost:1883

here is a random hostname inserted

3/30/2021, 4:04:07 PMnode: adf7f7a8.cc7ab8
random66 : msg : Object
object
payload: 67.1
topic: "random66"
_msgid: "f68cd504.395958"

You showed the ping earlier from a Windows machine, but the ping node is running on a pi, so you were not running the ping command on the same machine. However, if you put a random host in and get an output that is obviously not right.

I see that you are using an old version of node-red, but worse you are using a long superseded version of nodejs. The latest version of node 10 is 10.24.0, but v10 is itself only a few weeks from end of life. The fact that you have that version indicates that you maybe you did not use the recommended method of installing node-red on the pi. If you upgrade by running the script from that link it may fix the problem. Make sure your backups are up to date before running the script, though it should not affect your flows file.

You should also work out what the sacn node error is all about.

Thank you I will make the necessary updates to the pi.

I should have shown using the pi's terminal the ping, I was using the ipaddress to access the nodered on the pi.

I will follow up shortly

I performed the necessary updates, and cleared the errors you caught.

Starting as a systemd service.
30 Mar 22:12:29 - [info]
Welcome to Node-RED
===================
30 Mar 22:12:29 - [info] Node-RED version: v1.2.9
30 Mar 22:12:29 - [info] Node.js  version: v12.22.0
30 Mar 22:12:29 - [info] Linux 5.4.72-v7l+ arm LE
30 Mar 22:12:29 - [info] Loading palette nodes
30 Mar 22:12:31 - [info] +-----------------------------------------------------
30 Mar 22:12:31 - [info] | uibuilder initialised:
30 Mar 22:12:31 - [info] |   root folder: /home/pi/.node-red/uibuilder
30 Mar 22:12:31 - [info] |   version . .: 2.0.8
30 Mar 22:12:31 - [info] |   packages . : vue,bootstrap,bootstrap-vue,jquery,socket.io,ejs
30 Mar 22:12:31 - [info] +-----------------------------------------------------
30 Mar 22:12:31 - [info] Dashboard version 2.28.2 started at /ui
30 Mar 22:12:31 - [info] Settings file  : /home/pi/.node-red/settings.js
30 Mar 22:12:31 - [info] Context store  : 'default' [module=memory]
30 Mar 22:12:31 - [info] User directory : /home/pi/.node-red
30 Mar 22:12:31 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Mar 22:12:31 - [info] Flows file     : /home/pi/.node-red/flows_litserver.json
30 Mar 22:12:32 - [info] Server now running at http://127.0.0.1:1880/
30 Mar 22:12:32 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
30 Mar 22:12:32 - [info] Starting flows
30 Mar 22:12:32 - [info] Started flows
30 Mar 22:12:32 - [info] [sqlitedb:9c002548.be10b8] opened /home/pi/.node-red/sqlite_database_01.db ok
30 Mar 22:12:32 - [info] [mqtt-broker:MQTT Server PI] Connected to broker: mqtt://localhost:1883

the ping node is still behaving the same.

Also here is shot pinging from the pi terminal

pi@litserver:~ $ ping randomhostt
PING randomhostt (23.221.222.250) 56(84) bytes of data.
64 bytes from a23-221-222-250.deploy.static.akamaitechnologies.com (23.221.222.250): icmp_seq=1 ttl=50 time=64.2 ms
64 bytes from a23-221-222-250.deploy.static.akamaitechnologies.com (23.221.222.250): icmp_seq=2 ttl=50 time=64.5 ms
64 bytes from a23-221-222-250.deploy.static.akamaitechnologies.com (23.221.222.250): icmp_seq=3 ttl=50 time=64.9 ms
64 bytes from a23-221-222-250.deploy.static.akamaitechnologies.com (23.221.222.250): icmp_seq=4 ttl=50 time=64.4 ms
^C
--- randomhostt ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 64.222/64.515/64.904/0.353 ms

since im getting that using terminal, is my issue related to the pi system instead? (I am a little confused as to why it redirects to akamaitechnologiesDOTcom)

Try using another DNS server. Many ISP's and DNS servers use this as a default for unknown domain names.

1 Like

I will try that,

I found this link:
How to turn off the alternate DNS server setting on my phone/laptop?

but Im looking for how to do it on the pi. I will keep searching. thank you for the diagnosis, this seems reasonable why the ping function is behaving like that. The ping node is functioning "correctly".

On a pi you can edit the file /etc/resolv.conf. And change the nameserver to something like 1.1.1.1 or 8.8.8.8

1 Like

I currently get this:

# Generated by resolvconf
domain attlocal.net
nameserver 127.0.0.1

Would I also need to change the domain to something else when using 8.8.8.8?

It appears this is autogenerated, would it be better to edit /etc/network/interfaces and add

dns-nameservers 8.8.8.8

edit: just tried what I thought would work too, it did not work(rebooted as well). I will edit the file dceejay suggested and see what occurs.

edit2: tried what dceejay said and changed "127.0.0.1" to "8.8.8.8"

pi@litserver:~ $ ping random1234
PING random1234 (23.221.222.250) 56(84) bytes of data.
64 bytes from a23-221-222-250.deploy.static.akamaitechnologies.com (23.221.222.250): icmp_seq=1 ttl=50 time=66.4 ms
^C
--- random1234 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 66.382/66.382/66.382/0.000 ms
pi@litserver:~ $ 

still getting same thing. I'm clearly doing something wrong here.

You should not be using resolv.conf or network/interfaces any more with Debian/Raspbian. It is all in /etc/dhcpcd.conf (watch the spelling).

1 Like

Am I updating this portion?

interface wlan0
static ip_address=192.168.10.0
nohook wpa_supplicant
static routers=
static domain_name_servers=
static domain_search=

static domain_name_servers?

Yes. There should be commented out examples. You don't want that ip address though do you?
In fact I only use it when I want to set a static ip address. I am not sure whether you can leave out the ip address, and routers, so it will use dhcp (which is the default) and just set the domain_name_server. A typical example from mine is

interface wlan0
static ip_address=192.168.1.72/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 4.4.4.4
1 Like

I do require the IP to be static.

I updated the last portion to that line:

static domain_name_servers=8.8.8.8 4.4.4.4
pi@litserver:~ $ ping randomhdgdfjhgd
ping: randomhdgdfjhgd: Name or service not known

It worked!

I appreciate the prompt assistance, you have been helpful as always Colin!

something weird happened, after I used the exec node to perform a shutdown using a nodered button I am unable to ping through hostname again through the ping node. pinging works fine through the terminal. I tried resetting my router and restarting node-red service.

ping: zone4: Name or service not known

edit: I fixed it by deleting the ping node and replacing it and deploying