Report this

What is the reason for this report?

How to ping a private host within a private network by hostname and NOT private IP address

Posted on October 7, 2016

Hi,

I have created a Docker Swarm (private network) - complete with H/A & Im at the stage of setting up TLS…however the nodes must recognise each other from hostname and not ipaddress.

When I try to ping either of the 7 nodes within the private network using the hostname, it does not work, however I can ping with the private ip address.

I did try to set up a DNS - however this did not resolve my issue.

Thank you and look forward to any suggestions that may lead me to a solution.

Del



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

What about using hosts file? hosts will allow you to resolve host names to IP addresses.

Open hosts file with text editor of your choice:

  1. sudo nano /etc/hosts

There will probably be already some lines it. Add new line for example:

/etc/hosts
...
111.111.111.111    sammy2

Now if you ping sammy2 it should ping 111.111.111.111. If nothing happens try restarting your Droplet, but this should not be a case.

@sierracircle this is definitely the easiest/dirtiest solution. Problem is that propagation could take a while. New deployments and changes could take a while. But all the other options look exceedingly difficult for a small shop to implement. I may do this option and see how well I like it.

Hi,

Super suggestion, however, this was tried and failed also for me. I navigated to the sudo vim /etc/hosts file on one of my droplets and added all other 6 nodes in my swarm cluster (within the private network) and pinged the hostname associated with the node with no sucess, but all pings were successful when I pinged the actually address’s…

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.