Skip to content

Commit

Permalink
ansible: add getaddrinfo config to prefer IPv4
Browse files Browse the repository at this point in the history
On some hosts, IPv6 connectivity is limited and may result in DNS
lookups returning IPv6 addresses that the host is unable to reach.
Add a config file for glibc's getaddrinfo function that configures
IPv4 addresses to have higher precedence for such hosts.
  • Loading branch information
richardlau committed Nov 6, 2024
1 parent 478a534 commit c0cf64a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ansible/roles/bootstrap/files/gai.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# getaddrinfo(3) configuration file
# Settings to prefer IPv4 addresses for hosts with limited IPv6 connectivity.

# Below settings are documented defaults but need to be duplicated since
# setting any precedence line means the default table is not used.
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20

# This line is changed from the default to give IPv4 higher precedence.
precedence ::ffff:0:0/96 100
8 changes: 8 additions & 0 deletions ansible/roles/bootstrap/tasks/partials/rhel8-s390x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,11 @@
insertafter: ":OUTPUT ACCEPT.*]"
line: "-A INPUT -s 127.0.0.2/32 -d 127.0.0.1/32 -j ACCEPT"
notify: restart iptables

- name: Configure getaddrinfo to prefer IPv4 addresses
ansible.builtin.copy:
dest: /etc/gai.conf
group: root
mode: 0644
owner: root
src: "gai.conf"

0 comments on commit c0cf64a

Please sign in to comment.