# best way to go about dhcp

**URL:** <https://forum.ansible.com/t/best-way-to-go-about-dhcp/27536>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [May 15, 2018, 4:56pm UTC](https://forum.ansible.com/t/best-way-to-go-about-dhcp/27536 "2018-05-15T16:56:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [May 15, 2018, 4:56pm UTC](https://forum.ansible.com/t/best-way-to-go-about-dhcp/27536/1 "2018-05-15T16:56:53Z")

</div>

Hi, Posting a hypothetical.  
Since my windows environment relies on a hosts file with addresses in said file,  
what do you do when your environment is dhcp? Like if the IPs keep changing, whats to be done in the hosts file?

---

<div class="post-metadata">

**Author:** ![Richard\_Hector](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Richard\_Hector](https://forum.ansible.com/u/Richard_Hector)\
**Post date:** [May 16, 2018, 11:20am UTC](https://forum.ansible.com/t/best-way-to-go-about-dhcp/27536/2 "2018-05-16T11:20:45Z")

</div>

So the requirement is to be able to resolve a name to an IP address, to  
connect to the host, right?

If you want dynamic, changing ip addresses, you probably want to have  
the dhcp server update DNS (which means using DNS rather than hosts files)

Alternatively, make sure the ip addresses don't change - either set them  
statically on the machine (outside the dhcp dynamic range), or configure  
the dhcp server to allocate fixed addresses.

I don't use Windows, but I believe all those things are possible.

Richard

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [May 16, 2018, 11:43am UTC](https://forum.ansible.com/t/best-way-to-go-about-dhcp/27536/3 "2018-05-16T11:43:57Z")

</div>

Yes, DNS is what people normally use to resolve hostnames to IP addresses.

---

<div class="post-metadata">

**Author:** ![lpescatore](https://avatars.discourse-cdn.com/v4/letter/l/ccd318/32.png) [@lpescatore](https://forum.ansible.com/u/lpescatore)\
**Post date:** [May 16, 2018, 12:58pm UTC](https://forum.ansible.com/t/best-way-to-go-about-dhcp/27536/4 "2018-05-16T12:58:11Z")

</div>

Is there a module for dhcp scan?
