# Node-red-node-ping - Add options for IPv4/IPv6 selection

**URL:** <https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137>\
**Category:** Feature Requests\
**Created:** [17 February 2021 04:52 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137 "2021-02-17T04:52:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![leoneltoledo](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@leoneltoledo](https://discourse.nodered.org/u/leoneltoledo)\
**Post date:** [17 February 2021 04:52 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/1 "2021-02-17T04:52:55Z")

</div>

When using node-red-node-ping for communicate to an URL, there should be an option to select which IP version to use (Auto, IPv4 or IPv6). This will be useful to verify connectivity (Of node-red server's and/or destination server) for each protocol. It can be set as Auto by default.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [17 February 2021 08:01 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/2 "2021-02-17T08:01:12Z")

</div>

I looked at the node. I could add this feature for Linux, however I'd need help to bring all supported platforms up to date.

relevant code in the node:

```auto
if (plat == "linux" || plat == "android") {
            commandLineOptions = ["-n", "-w", timeoutS, "-c", "1"]
        } else if (plat.match(/^win/)) {
            commandLineOptions = ["-n", "1", "-w", hostOptions.timeout]
        } else if (plat == "darwin" || plat == "freebsd") {
            commandLineOptions = ["-n", "-t", timeoutS, "-c", "1"]
        } else {
            node.error("Sorry - your platform - "+plat+" - is not recognised.", msg);
            return; //dont pass go - just return!
        }

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [17 February 2021 09:44 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/3 "2021-02-17T09:44:43Z")

</div>

By all means create a Pull request - but yes ideally it would ned to work across all platforms (otherwise the UI would then have to allow selection per platform - and moving flows from one platform to another may break etc... - but surely the help pages for ping on each platform can help 🙂

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [18 February 2021 05:10 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/4 "2021-02-18T05:10:30Z")

</div>

I'll Code it up this weekend and put a pull request. Would you like me to take a stab at  
darwin AKA Mac, and Windows? ? It would have to go in the beta branch and let users that have them OS's test it for me.

I can do the linux tests.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 February 2021 08:01 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/5 "2021-02-18T08:01:28Z")

</div>

Yes. Sounds good.

---

<div class="post-metadata">

**Author:** ![leoneltoledo](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@leoneltoledo](https://discourse.nodered.org/u/leoneltoledo)\
**Post date:** [18 February 2021 16:12 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/7 "2021-02-18T16:12:26Z")

</div>

For windows, CLI modifiers are -4 and -6:

ping [www.example.com](http://www.example.com) - Automatic selection of protocol (IPv6 takes preference, I believe)  
ping -4 [www.example.com](http://www.example.com) - IPv4  
ping -6 [www.example.com](http://www.example.com) - IPv6

For MacOS, ping man page doesn't list an option to make the choice. I'm asking to people who do use the system to provided the data, if indeed the choice exists

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 February 2021 16:17 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/8 "2021-02-18T16:17:34Z")

</div>

I think you have to use ping6 command for mac

---

<div class="post-metadata">

**Author:** ![leoneltoledo](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@leoneltoledo](https://discourse.nodered.org/u/leoneltoledo)\
**Post date:** [18 February 2021 18:23 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/9 "2021-02-18T18:23:08Z")

</div>

For MacOS. "ping" is used for IPv4, and "ping6" is used for IPv6.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [18 February 2021 21:44 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/10 "2021-02-18T21:44:28Z")

</div>

> [@leoneltoledo](#):
>
> node-red-node-ping

Thanks for the help guys .... keep it coming.  
I've started pecking at it as of today.

![ping1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/2008d78a047e0a40b4321092ed1b423e4786ea4a.jpeg)

- **User interface** ( the node's properties ) and locals - I don't think It should have a AUTO option. Just defaults to IPv4 and user can select IPv6. I don't want to make any breaking changes!!! It should work as it does now for current user flows. I was going to add the ability to change it on input **Triggered** but decided to let users sort it out with a switch node. they then can pipe it to the IPv4 or IPv6 one they have set.

- **Node status** - while I'm here updating this node do we want to add status msg's to this node? someting like. blue\_dot IPv6 - 12ms , red\_dot false

- **Input and or Output msg.InternetProtocolVersion** - I don't want to add this and I don't think I will for the first Pull request I send up the chain. If there is enough demand and @dceejay says "DO IT" I can add the ability to set the Protocol via a input msg and the output msg would let users know what version is selected via the drop down and or sent via input msg.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [18 February 2021 21:50 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/11 "2021-02-18T21:50:08Z")

</div>

I'm doing this the proper way using the locals. If there is a Japanese speaker here please let me know now and I can update it if you don't know how to code or submit a pull request that's fine ill do all that. Just need help in the translation.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 February 2021 22:57 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/12 "2021-02-18T22:57:28Z")

</div>

All sounds sensible steps so far, keeping them separate is sensible as the target can be a list so trying to handle different per each would be a pain..  
Status maybe, but again how would you handle a list of targets ? So maybe not.. But by all means set the label to ping6 if appropriate.  
We can get translations done when you raise the PR as it will be easy to see the missing fields... Or indeed add them to the other locales in English to make them obvious..

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [18 February 2021 23:26 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/13 "2021-02-18T23:26:37Z")

</div>

> [@meeki007](#):
>
> InternetProtocolVersion

Oh the joy of making things cross platform compatible.

So I have to use a automatic as @leoneltoledo suggested as it would create a breaking change if i force windows users with a -4 for IPv4. however linux users like me have been using ping for IPv4 stuff and ping6 for IPv6.....there is no Auto/Default fallback.

however arch based dist uses -6 so I'm going with Auto for now and figuring out how to deal with all these operating systems.....

Working on how

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [19 February 2021 16:00 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/14 "2021-02-19T16:00:29Z")

</div>

Fired up a server instance as I could not trust my double NAT network from home. Sorted out ipv6 networking on server and here are the results for Linux for any one who wants to know.

Ubuntu 20.04

**ping** will default to ipv6 if its avalible

 ![x_ping](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/02072fce58337d9cc8a478b9fe56a31ff3a33dca.jpeg)

**ping6** as expected

 ![x_ping6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/f/8fe65562901d17338a55e05c96d5477d62bd25d5.jpeg)

**ping -6** \* also works ... interesting

 ![x_ping-4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/a/ca218dfbd61f68ee18a15bdbebcf3d3e031ce199.jpeg)

**ping -4** forces ipv4

 ![x_ping-4](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/7/179b23f2373bc5e250e9d060b6ae3021439a6a07.jpeg)

Now knowing how it works I can move on to code........  
Info for who ever might want to know

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [19 February 2021 16:29 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/15 "2021-02-19T16:29:46Z")

</div>

OH and i missed that ping6 was merged into ping years ago 😛  
[https://github.com/iputils/iputils/commit/ebad35fee3de851b809c7b72ccc654a72b6af61d](https://github.com/iputils/iputils/commit/ebad35fee3de851b809c7b72ccc654a72b6af61d)

---

<div class="post-metadata">

**Author:** ![leoneltoledo](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@leoneltoledo](https://discourse.nodered.org/u/leoneltoledo)\
**Post date:** [19 February 2021 16:40 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/16 "2021-02-19T16:40:45Z")

</div>

For Windows, ping6 doesn't exist. All other commands listed work in the same way. ( **ping** without modifiers will also default to ipv6 if it is available)

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [19 February 2021 19:25 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/17 "2021-02-19T19:25:55Z")

</div>

Request help from mac OSX guys....

So the command **ping -t** is the timeout but...  
**ping6** in mac has no timeout ??? ---\> [https://www.unix.com/man-page/osx/8/ping6/](https://www.unix.com/man-page/osx/8/ping6/)  
unlike in linux -w is not the timeout for OSX ping6

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [19 February 2021 22:21 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/18 "2021-02-19T22:21:36Z")

</div>

FreeBSD has merged ping6 and ping as of late 2019 and it looks like OSX will follow that soon. So I've coded it up to bank on that fact.

Pull request sent ---\> [https://github.com/node-red/node-red-nodes/pull/758](https://github.com/node-red/node-red-nodes/pull/758)

for everyone else who wants to test I will post the files here in an hour.

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [19 February 2021 23:45 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/19 "2021-02-19T23:45:46Z")

</div>

To join in the English beta testing of these changes you need to download or have installed:  
node-red-node-ping ---\> [node-red-node-ping (node) - Node-RED](https://flows.nodered.org/node/node-red-node-ping)

Then in your Node-RED user directory - typically `~/.node-red`  
find /node\_modules dir and in that directory find /node-red-node-ping directory  
on linux. The path for me looks like /home/meeki/.node-red/node\_modules/node-red-node-ping

You need to overwrite 88-ping.html and 88-ping.js

Then in the /locales/en-US folder ; for me its located at path /home/meeki/.node-red/node\_modules/node-red-node-ping/locales/en-US you need to overwrite 88-ping.html and 88-ping.json  
then restart node-red  
**NOTE: 88-ping.html is the same name as the file above but its contents are not. Use the correct file from downloads below!**

the files ---\> [https://filebin.net/1mnsil8x35575pd5](https://filebin.net/1mnsil8x35575pd5)  
the /locales/en-US files ---\> [https://filebin.net/c1h9ihd5ixf5g6je](https://filebin.net/c1h9ihd5ixf5g6je)

let me know if you have issues

**PS** : as always I will post about security. Even though you can read what the code does, you may not understand it.

SECURITY NOTE: I see people just willy nilly downloading files. You don't know me. I don't have a community of checkers making sure I'm not bitcoin mining.

Before you download ask yourself if you really should trust the source. If you feel fine then great, but do question before downloading any file that is not official.

If you don't understand the code think twice.

---

<div class="post-metadata">

**Author:** ![leoneltoledo](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@leoneltoledo](https://discourse.nodered.org/u/leoneltoledo)\
**Post date:** [12 March 2021 15:55 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/20 "2021-03-12T15:55:39Z")

</div>

The links for the test files expired. Is there a timeline to include the changes in the main node, or can you provide new links for the beta version?

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [12 March 2021 19:06 UTC](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137/21 "2021-03-12T19:06:28Z")

</div>

good news It just got merged ----\> [Add IPv6 support to node by meeki007 · Pull Request #758 · node-red/node-red-nodes · GitHub](https://github.com/node-red/node-red-nodes/pull/758)

@leoneltoledo It was a limited beta. Testing is over. feel free to edit and copy and paste from the links to the pull request to edit your own files if you like. I am no longer going to host the changes.

Look for them in the next node-red update.

[Next page](https://discourse.nodered.org/t/node-red-node-ping-add-options-for-ipv4-ipv6-selection/41137.md?page=2)
