I'm trying to get mod_security and hit the very common hostname error of
[alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "computername.domain.com"
This normally means an entry is required in the hosts file. However I have tried all combinations for the hostname; localhost (127.0.0.1), local IP address (192.168….) and public IP address ("122.56.11.156"). I have also tried all combinations for Apache's ServerName; computer.domain, domain, IP addresses and not setting it at all. Nothing seems to work for me.
Currently my /etc/hosts file looks like:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 computername.domain.com computername localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.0.102 computername.domain.com computername
#192.168.0.102 computername.hostingprovider.local computername # NIC <eth0>
#122.56.11.156 computername.domain.com computername
Ping works, also hostname shows
[root@computername~]# hostname
computername.domain.com
The public dns doesn't have computername as a subdomain so what is the correct IP address / ServerName combo to use? What happens with duplicate entries on hosts? What does mod_unqiue_id check that could cause it to fail?
Thanks for any help you can provide
The underlying problem
Thanks for the strace suggestion. On starting apache I got the following.
1377 open("/etc/hosts", O_RDONLY) = -1 EACCES (Permission denied)
So quickly sanity check permissions and:
# ll /etc/hosts
-rw-r--r-- 2 root root 608 Jul 22 16:01 /etc/hosts
But turned out be SELinux, see below
Best Answer
The problem was SELinux
In my case the following solved it: