# Access pods by hostnames

**URL:** <https://forums.suse.com/t/access-pods-by-hostnames/38144>\
**Category:** SUSE Rancher Prime\
**Created:** [June 11, 2022, 6:37pm UTC](https://forums.suse.com/t/access-pods-by-hostnames/38144 "2022-06-11T18:37:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jspera](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/jspera/32/9096_2.png) [@jspera](https://forums.suse.com/u/jspera)\
**Post date:** [June 11, 2022, 6:37pm UTC](https://forums.suse.com/t/access-pods-by-hostnames/38144/1 "2022-06-11T18:37:53Z")

</div>

Hi I am trying to get 2 pods within the same nodes to communicate with each other via their hostnames. Following this guide, I have tried a few approaches and here are the results:

Pod A: 10.42.0.11  
Pod B: 10.42.0.12

Pod A ping Pod B via default DNS name (10-42-0-12.default.pod.cluster.local) → Works  
Pod A ping Pod A hostname and subdomain (eg, pod-a-hostname.subdomain.default.pod.cluster.local) → Works  
Pod A ping Pod B hostname and subdomain (eg, pod-b-hostname.subdomain.default.pod.cluster.local) → Does not work

May I know how can I setup a DNS name that allows Pod A and B to communicate with each other without knowing each other’s IP.

---

<div class="post-metadata">

**Author:** ![wcoateRR](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/wcoaterr/32/8144_2.png) [@wcoateRR](https://forums.suse.com/u/wcoateRR)\
**Post date:** [June 13, 2022, 1:53pm UTC](https://forums.suse.com/t/access-pods-by-hostnames/38144/2 "2022-06-13T13:53:24Z")

</div>

Does [DNS for Services and Pods | Kubernetes](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/) help? I’m not sure where the subdomain is coming from, but I’d think if default is the namespace for the pods then I’d think they should work if you get rid of the subdomain. Additionally, if they’re in the same namespace then just going by name is supposed to work, but you might need to open a shell in the pods and verify their resolv.conf files for their search criteria and that they’ve properly got the coreDNS pod set as their DNS.
