Bug 2222913

Summary: systemd_myhostname returns ipv6 address for local host even when ipv6 is disabled
Product: Red Hat Enterprise Linux 8 Reporter: Carlos Santos <casantos>
Component: systemdAssignee: systemd maint <systemd-maint>
Status: NEW --- QA Contact: Frantisek Sumsal <fsumsal>
Severity: high Docs Contact:
Priority: high    
Version: 8.8CC: systemd-maint
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Carlos Santos 2023-07-14 13:02:41 UTC
Description of problem:

systemd_myhostname returns ipv6 address for local host even when ipv6 is
disabled

Version-Release number of selected component (if applicable):

glibc-2.28-225.el8.x86_64
systemd-libs-239-74.el8_8.x86_64

How reproducible:

Always

Steps to Reproduce:
1. Disable IPv6

   # sysctl -w net.ipv6.conf.all.disable_ipv6=1

2. Set the host name to something *not* in /etc/hosts nor in DNS

   # hostnamectl set-hostname nowhere
   # hostname
   nowhere
   # hostname -f
   nowhere

3. Query the hosts database using the three services:

   # getent -s files hosts nowhere
   # getent -s dns hosts nowhere
   # getent -s myhostname hosts nowhere

Actual results:

   ::1             nowhere localhost

Expected results:

   The machine IPv4 address, e.g.

   192.168.122.71  nowhere

Additional info:

Same results are seen on RHEL 9. It should not return an IPv6 address with
net.ipv6.conf.all.disable_ipv6=1.

Repeating the same test on a fully updated RHEL 7.9, we get

   # getent -s myhostname hosts nowhere
   192.168.122.71  nowhere