Why does "hostname -I" command give error while using IPv6 ?
Environment
- Red Hat Enterprise Linux 6
Issue
- hostname -I command gives error hostname lookup failure for IPv6 address on Red Hat Enterprise Linux 6
- Here is how the /etc/hosts looks like
127.0.0.1 localhost.localdomain localhost
:: localhost6.localdomain6 localhost6
2001:fe80:XX:baac:6fff:fe12:5552 hostname
Resolution
- This is a bug in net-tools. This is fixed in net-tools-1.60-109.el6.1 on RHEL 6.3
Root Cause
- It is bug in net-tools
Diagnostic Steps
- Make sure ipv6 is enabled in the system.
- Check sosreport, version of net-tools.
Output of "hostname -I" on machine which is configured with IPv6 address only:
cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
20XX1:XXX:1950::a hostname
[root@ ~]# hostname -I
hostname: Host name lookup failure
Output of "hostname -I" on machine which is configured with both ipv4 A& IPv6 address :
[root@ ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
2001:XXX:1950::a hostname
10.XXX.254 hostname
[root@ ~]# hostname -I
10.XXX.254 2001:XXX:1950::a
[root@ ~]#
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
