Question

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

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


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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.

I have used BIND as DNS to do what you are talking about, but it did not work every time, and my knowledge was not sufficient to trouble-shoot to find out why it failed sometimes. I was also trying to use it in conjunction with OpenVPN, so there were other variables at play.

Another method that will work, but might not be the best of ways…but will work…

Purchase a domain. get a cheap domain, like .space or .biz

create a subdomain for each node or droplet with the private ip address

once those subdomains propagate, then your nodes should be able to ping each other using your subdomains.

I have done this before and it works…but bear in mind it will only work within the network cluster or whatever it is you are doing…external computers that are not on that network will get a “Cannot connect to host.”

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…