Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

time out problem with gethostbyaddr() function in php

Tags:

php

recently i noticed that on my new server the gethostbyaddr() function which is used on my site to get the referes' hosts, it makes the page load 5 times slower.

and when I removed it the time out problem is gone

what is wrong with this function and my new Centos linux server config.

and what else i can use instead of this php function to get the host name of my referers.

like image 537
Mac Taylor Avatar asked Jun 26 '26 15:06

Mac Taylor


1 Answers

It may be a temporary slowness in DNS resolution and it may clear itself up later. There really isn't any alternative to gethostbyaddr() other than to make a system call like the following from PHP. (gethostbyaddr() does essentially this anyway)

`nslookup $ip_address`
// Or
`host $ip_address`

You can test to see if resolutions are slow from the command line with :

# choose an IP address you know the resolution of...
$ host 123.123.123.123

If this doesn't return quickly you may have a DNS problem.

Check the contents of /etc/resolv.conf and if you have an alternate DNS server you can point it to, try that one instead.

like image 102
Michael Berkowski Avatar answered Jun 29 '26 04:06

Michael Berkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!