# Force ansible to use IPv4 / IPv6?

**URL:** <https://forum.ansible.com/t/force-ansible-to-use-ipv4-ipv6/17244>\
**Category:** Ansible Project\
**Created:** [January 13, 2015, 12:04am UTC](https://forum.ansible.com/t/force-ansible-to-use-ipv4-ipv6/17244 "2015-01-13T00:04:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Oliver](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@John\_Oliver](https://forum.ansible.com/u/John_Oliver)\
**Post date:** [January 13, 2015, 12:04am UTC](https://forum.ansible.com/t/force-ansible-to-use-ipv4-ipv6/17244/1 "2015-01-13T00:04:52Z")

</div>

I’ve run into a minor problem where one of my hosts has an AAAA record for an address assigned via DHCP6, but it isn’t acquiring that address. I can connect via the IPv4 address just fine. I’m looking for a switch to tell ansible / ansible-playbook to force a connection over one protocol so I don’t have to come up with some lower-level hack, forget about it, and have it cause another problem tomorrow 🙂

---

<div class="post-metadata">

**Author:** ![Greg\_Andrews](https://avatars.discourse-cdn.com/v4/letter/g/6bbea6/32.png) [@Greg\_Andrews](https://forum.ansible.com/u/Greg_Andrews)\
**Post date:** [January 13, 2015, 2:42am UTC](https://forum.ansible.com/t/force-ansible-to-use-ipv4-ipv6/17244/2 "2015-01-13T02:42:46Z")

</div>

Off the top of my head:

1. Do the IPv4 and IPv6 addresses have different hostnames in DNS? If so, use the hostname for the address that’s usable.
2. In the ansible machine’s .ssh/config file, you can enter something like this:

HOST problem-hostname  
AddressFamily inet

According to my man page for ssh\_config, “inet” is IPv4 and “inet6” is IPv6.

-Greg

---

<div class="post-metadata">

**Author:** ![Tom\_Bamford](https://avatars.discourse-cdn.com/v4/letter/t/c2a13f/32.png) [@Tom\_Bamford](https://forum.ansible.com/u/Tom_Bamford)\
**Post date:** [January 13, 2015, 7:48am UTC](https://forum.ansible.com/t/force-ansible-to-use-ipv4-ipv6/17244/3 "2015-01-13T07:48:54Z")

</div>

Should be able to do this with ssh-config.

Don’t forget to tell your client to fix their brain-dead DNS! 🙂
