# How to use Ansible with clients that have dynamic (DHCP) IPs?

**URL:** <https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [July 26, 2019, 9:47pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885 "2019-07-26T21:47:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Fahrner](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Matt\_Fahrner](https://forum.ansible.com/u/Matt_Fahrner)\
**Post date:** [July 26, 2019, 9:47pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/1 "2019-07-26T21:47:31Z")

</div>

Since Ansible is clientless, if say you were trying to manage Windows or Mac laptops that didn’t have fixed IPs (eg: DHCP clients), how do you solve this scenario?

Do you use Dynamic DNS (DDNS)?

Have others solved this - seems almost like you need a minor agent for registration but…

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 26, 2019, 10:26pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/2 "2019-07-26T22:26:27Z")

</div>

That is a general issue with hosts that have dynamic addresses.  
DDNS is one example of how to address that - this in fact is 'a minor  
agent' as you call it.  
There is no single solution, and it is not specific to ansible.

Dick

---

<div class="post-metadata">

**Author:** ![Matt\_Fahrner](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Matt\_Fahrner](https://forum.ansible.com/u/Matt_Fahrner)\
**Post date:** [July 26, 2019, 10:48pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/3 "2019-07-26T22:48:45Z")

</div>

Thanks Dick - I get your point. That said, not that this is the direction I want to go at the moment, Puppet does have agents that slightly simplify this particular part of the problem.

Anyway, good to have confirmation that DDNS is on the right track.

Thanks again!

---

<div class="post-metadata">

**Author:** ![Jonathan\_Lozada\_De\_L](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jonathan\_Lozada\_De\_L](https://forum.ansible.com/u/Jonathan_Lozada_De_L)\
**Post date:** [July 26, 2019, 10:57pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/4 "2019-07-26T22:57:13Z")

</div>

you can potentially create or search for a dynamic inventory script that can pull your addresses from whatever provides dhcp. You must have a list somewhere so check how you can pull that. You can also do a static inventory and do ranges. So for example, if your range of windows are in 192.168.50.1-192.168.50.200. Worse case scenario you can use an inventory that has all the ranges of IP and do tasks based on facts. There’s option but, you have to find what works for you.

Jonathan Lozada De La Matta on mobile

– You received this message because you are subscribed to the Google Groups “Ansible Project” group. To unsubscribe from this group and stop receiving emails from it, send an email to . To view this discussion on the web visit .

---

<div class="post-metadata">

**Author:** ![Matt\_Fahrner](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Matt\_Fahrner](https://forum.ansible.com/u/Matt_Fahrner)\
**Post date:** [July 26, 2019, 11:02pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/5 "2019-07-26T23:02:02Z")

</div>

That’s certainly a possibility, though it starts to be a little impractical as you start to size out. Still, something to think about - thanks!

---

<div class="post-metadata">

**Author:** ![mailinglists-ansible](https://avatars.discourse-cdn.com/v4/letter/m/9d8465/32.png) [@mailinglists-ansible](https://forum.ansible.com/u/mailinglists-ansible)\
**Post date:** [July 27, 2019, 7:57am UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/6 "2019-07-27T07:57:12Z")

</div>

You also could use an automatc VPN client and the corresponding IP; this  
also works for DHCP Clients that are leaving your network.  
(relevant for homeoffices etc).

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [July 27, 2019, 8:21am UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/7 "2019-07-27T08:21:57Z")

</div>

Ansible also have a "agent" ansible-pull run from crontab.

---

<div class="post-metadata">

**Author:** ![Matt\_Fahrner](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Matt\_Fahrner](https://forum.ansible.com/u/Matt_Fahrner)\
**Post date:** [July 27, 2019, 3:13pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/8 "2019-07-27T15:13:34Z")

</div>

Thank you - very helpful!!!

---

<div class="post-metadata">

**Author:** ![Matt\_Fahrner](https://avatars.discourse-cdn.com/v4/letter/m/919ad9/32.png) [@Matt\_Fahrner](https://forum.ansible.com/u/Matt_Fahrner)\
**Post date:** [August 15, 2019, 2:52pm UTC](https://forum.ansible.com/t/how-to-use-ansible-with-clients-that-have-dynamic-dhcp-ips/30885/9 "2019-08-15T14:52:48Z")

</div>

Mean to respond to this earlier. Thank you - yes VPN is a possibility here as well.

Thanks again.
