# connect without dns or /etc/hosts" resolution

**URL:** <https://forum.ansible.com/t/connect-without-dns-or-etc-hosts-resolution/30274>\
**Category:** Ansible Project\
**Created:** [May 7, 2019, 9:14am UTC](https://forum.ansible.com/t/connect-without-dns-or-etc-hosts-resolution/30274 "2019-05-07T09:14:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![christian.tremel](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@christian.tremel](https://forum.ansible.com/u/christian.tremel)\
**Post date:** [May 7, 2019, 9:14am UTC](https://forum.ansible.com/t/connect-without-dns-or-etc-hosts-resolution/30274/1 "2019-05-07T09:14:56Z")

</div>

i have a dynamic inventory script which outputs the following.

`  
“NODE\_A”: {  
“inventory\_hostname”: “10.0.2.6”,  
“inventory\_lparname”: “NODE\_A”  
}

`

the nodes are not resolvable via dns or something as this network is some kind of isolated “management” lan.

until now i had a play running which modifies the local /etc/hosts file to enable name resolution. as the ansible controller is going to move to an foreign machine, this is not possible anymore.

so the big question is how to proceed. how do i instruct ansible to connect to the ip adress instead of the hostname repectively can i use inventory\_hostname instead of ansible\_hostname as connection string, but keep the hostname displayed in the play recap?

chris

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [May 7, 2019, 2:11pm UTC](https://forum.ansible.com/t/connect-without-dns-or-etc-hosts-resolution/30274/2 "2019-05-07T14:11:33Z")

</div>

You need to use the special variable called ansible\_host to indicate the IP address of the host, instead of using inventory\_hostname.

inventory\_hostname is an internally calculated variable, as such Ansible doesn’t use it from any external source.
