[PHP] gethostbyname () uses old DNS server
Hi, We have moved our DNS server from one IP to another. But on a Linux server, the PHP programs keep using the old DNS server IP. For example, for a simple php file: ? echo gethostbyname (smtp.cpttm); ? When it is run, it tries to lookup smtp.cpttm using the old DNS server (I know it using tcpdump). The new DNS server is specified in /etc/resolv.conf. If I issue ping smtp.cpttm in a command prompt, then tcpdump shows that it is accessing the new DNS server. Any idea? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname () uses old DNS server
Kent Tong wrote: We have moved our DNS server from one IP to another. But on a Linux server, the PHP programs keep using the old DNS server IP. For example, for a simple php file: ? echo gethostbyname (smtp.cpttm); ? When it is run, it tries to lookup smtp.cpttm using the old DNS server (I know it using tcpdump). The new DNS server is specified in /etc/resolv.conf. If I issue ping smtp.cpttm in a command prompt, then tcpdump shows that it is accessing the new DNS server. Assuming you're using a web server it's possible PHP is caching the DNS server details. Try restarting the web server. Alternatively try the same script on the command line. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname () uses old DNS server
On Mon, March 26, 2007 4:21 am, Kent Tong wrote: We have moved our DNS server from one IP to another. But on a Linux server, the PHP programs keep using the old DNS server IP. For example, for a simple php file: ? echo gethostbyname (smtp.cpttm); ? When it is run, it tries to lookup smtp.cpttm using the old DNS server (I know it using tcpdump). The new DNS server is specified in /etc/resolv.conf. If I issue ping smtp.cpttm in a command prompt, then tcpdump shows that it is accessing the new DNS server. Any idea? Thanks. Check /etc/hosts Try doing the same thing from the command line. And did you re-start apache so PHP could forget any DNS entries in any cache it might have? There may be something akin to clearstatcache for DNS in PHP as well. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname () uses old DNS server
On 3/26/07, Richard Lynch [EMAIL PROTECTED] wrote: On Mon, March 26, 2007 4:21 am, Kent Tong wrote: We have moved our DNS server from one IP to another. But on a Linux server, the PHP programs keep using the old DNS server IP. For example, for a simple php file: ? echo gethostbyname (smtp.cpttm); ? When it is run, it tries to lookup smtp.cpttm using the old DNS server (I know it using tcpdump). The new DNS server is specified in /etc/resolv.conf. If I issue ping smtp.cpttm in a command prompt, then tcpdump shows that it is accessing the new DNS server. Any idea? Thanks. Check /etc/hosts Try doing the same thing from the command line. And did you re-start apache so PHP could forget any DNS entries in any cache it might have? There may be something akin to clearstatcache for DNS in PHP as well. This problem is also solved already Richard... Tijnema -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
On Thursday 09 November 2006 21:28, Chris [EMAIL PROTECTED] sent a missive stating: Henrik Hudson wrote: Thanks for the input everyone. It seems it Apache itself can't do lookups either (ie: Hostnamelookups On ..doesn't actually do anything..so, going to hunt down the issues inside Apache...) funny thing is I've got a test server with the same exact port versions and almost identical config files, so..I don't know...perl scripts and php from the CLI work fine..so my actual DNS resolution is working okay..just Apache is losing it somewhere...if anyone has some thoughts..let me know :) Hostname lookups has *nothing* to do with this issue. It only affects apache. http://httpd.apache.org/docs/1.3/mod/core.html#hostnamelookups Yeah, I know that. I was using it as another test. When I turn this On, it doesn't actually perform the lookups and I still just got IP numbers in all my logs. As someone else mentioned, freebsd has issues with this stuff when it's running inside a chroot'ed environment. Are you running in a chroot'ed or selinux or anything like that? Nope, no chroot's, jails or funky security levels. Henrik -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
FYI: I uninstalled Apache 2.2.3 and installed Apache 1.3.x via ports and now everything works flawlessly. I made zero other changes on the system between working and not working, so there either is a bug or something wierd. I was running dnstop and when asking the server to do hostnamelookups on or DNS lookups inside the php module is was generating 0 DNS requests to anywhere. Now, with 1.3 installed dnstop is showing plenty of traffic. \On Thursday 09 November 2006 15:27, Henrik Hudson [EMAIL PROTECTED] sent a missive stating: Hey List- running: apache 2.2, freebsd 6.2 and php 4.4.4 I've got a wierd issue. I've got a script that does this: $domain = www.google.com; $ip = gethostbyname($domain); echo $ip; $hostname = gethostbyaddr(72.14.205.99); echo $hostname; Using dig, ping, etc... to confirm name resolution is working works fine. Running that script from the CLI is fine (ie: php test.php). However, when running from the web it doesn't work. I tried it on a php 5.1.x box and it works fine there. Thoughts? Henrik -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gethostbyname failing?
Hey List- running: apache 2.2, freebsd 6.2 and php 4.4.4 I've got a wierd issue. I've got a script that does this: $domain = www.google.com; $ip = gethostbyname($domain); echo $ip; $hostname = gethostbyaddr(72.14.205.99); echo $hostname; Using dig, ping, etc... to confirm name resolution is working works fine. Running that script from the CLI is fine (ie: php test.php). However, when running from the web it doesn't work. I tried it on a php 5.1.x box and it works fine there. Thoughts? Henrik -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
Henrik Hudson wrote: Hey List- running: apache 2.2, freebsd 6.2 and php 4.4.4 I've got a wierd issue. I've got a script that does this: $domain = www.google.com; $ip = gethostbyname($domain); echo $ip; $hostname = gethostbyaddr(72.14.205.99); echo $hostname; Using dig, ping, etc... to confirm name resolution is working works fine. Running that script from the CLI is fine (ie: php test.php). However, when running from the web it doesn't work. I tried it on a php 5.1.x box and it works fine there. Thoughts? Henrik ?php echo 'pre'; print_r( gethostbynamel('www.google.com') ); ? Array ( [0] = 209.85.135.103 [1] = 209.85.135.104 [2] = 209.85.135.147 [3] = 209.85.135.99 ) Jürgen -- View this message in context: http://www.nabble.com/gethostbyname-failing--tf2604272.html#a7267120 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
On Thursday 09 November 2006 15:56, Jürgen Wind [EMAIL PROTECTED] sent a missive stating: Henrik Hudson wrote: Hey List- running: apache 2.2, freebsd 6.2 and php 4.4.4 I've got a wierd issue. I've got a script that does this: $domain = www.google.com; $ip = gethostbyname($domain); echo $ip; $hostname = gethostbyaddr(72.14.205.99); echo $hostname; Using dig, ping, etc... to confirm name resolution is working works fine. Running that script from the CLI is fine (ie: php test.php). However, when running from the web it doesn't work. I tried it on a php 5.1.x box and it works fine there. Thoughts? Henrik ?php echo 'pre'; print_r( gethostbynamel('www.google.com') ); ? Array ( [0] = 209.85.135.103 [1] = 209.85.135.104 [2] = 209.85.135.147 [3] = 209.85.135.99 ) Yes, I get nothing when running inside Apache. I get no errors in my logs either. However, again when I do it from the CLI I get: preArray ( [0] = 72.14.205.99 [1] = 72.14.205.104 ) So, is this a bug in the php module? a setting in Apache? a setting in my php.ini? or ??? I also tried a perl script which works fine both from the CLI and inside Apache. Henrik -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
On 09 Nov 2006, at 15:09 , Henrik Hudson wrote: On Thursday 09 November 2006 15:56, Jürgen Wind [EMAIL PROTECTED] sent a missive stating: ?php echo 'pre'; print_r( gethostbynamel('www.google.com') ); ? Yes, I get nothing when running inside Apache. http://akane.covisp.net/~kreme/test.php http://akane.covisp.net/~kreme/test.phps Works fine here... -- I want to get hurt! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
maybe this is related: from http://de3.php.net/manual/en/function.gethostbyname.php (user comments) christian at SPAM at IS at DEAD at MEAT at karg dot org 01-Apr-2003 02:12 I had difficulty getting gethostbyname to work under OpenBSD 3.2 and Apache, until I discovered that the default Apache chroot caused the problem. To get PHP's gethostbyname to work, you need resolv.conf (and possibly hosts) in /var/www/etc (assuming default install dirs). -- View this message in context: http://www.nabble.com/gethostbyname-failing--tf2604272.html#a7268131 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
Thanks for the input everyone. It seems it Apache itself can't do lookups either (ie: Hostnamelookups On ..doesn't actually do anything..so, going to hunt down the issues inside Apache...) funny thing is I've got a test server with the same exact port versions and almost identical config files, so..I don't know...perl scripts and php from the CLI work fine..so my actual DNS resolution is working okay..just Apache is losing it somewhere...if anyone has some thoughts..let me know :) On Thursday 09 November 2006 15:27, Henrik Hudson [EMAIL PROTECTED] sent a missive stating: Hey List- running: apache 2.2, freebsd 6.2 and php 4.4.4 I've got a wierd issue. I've got a script that does this: $domain = www.google.com; $ip = gethostbyname($domain); echo $ip; $hostname = gethostbyaddr(72.14.205.99); echo $hostname; Using dig, ping, etc... to confirm name resolution is working works fine. Running that script from the CLI is fine (ie: php test.php). However, when running from the web it doesn't work. I tried it on a php 5.1.x box and it works fine there. Thoughts? Henrik -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- Henrik Hudson [EMAIL PROTECTED] -- God, root, what is difference? Pitr; UF (http://www.userfriendly.org/) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname failing?
Henrik Hudson wrote: Thanks for the input everyone. It seems it Apache itself can't do lookups either (ie: Hostnamelookups On ..doesn't actually do anything..so, going to hunt down the issues inside Apache...) funny thing is I've got a test server with the same exact port versions and almost identical config files, so..I don't know...perl scripts and php from the CLI work fine..so my actual DNS resolution is working okay..just Apache is losing it somewhere...if anyone has some thoughts..let me know :) Hostname lookups has *nothing* to do with this issue. It only affects apache. http://httpd.apache.org/docs/1.3/mod/core.html#hostnamelookups As someone else mentioned, freebsd has issues with this stuff when it's running inside a chroot'ed environment. Are you running in a chroot'ed or selinux or anything like that? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] gethostbyname() time issues
The following script: ?php $url_array = array( 'http://www.imakenews.com/progresspsdn/e_rss.aspx', 'http://rssnewsapps.ziffdavis.com/eweekdeveloper.xml', 'http://itpapers.zdnet.com/xml/RSS-239.xml', 'http://rssnewsapps.ziffdavis.com/eweeklinux.xml' ); foreach( $url_array as $url ) { $rdf = parse_url($url); $timestart = microtime(); $h = gethostbyname($rdf['host']); $timeend = microtime(); $diff = number_format(((substr($timeend,0,9)) + (substr($timeend,-10)) - (substr($timestart,0,9)) - (substr($timestart,-10))),4); echo gethostbyname(.$rdf['host'].) took $diff s and resolved to $hbr\n; } ? takes less than 1 second on CLI: # php gethostbyname.php Content-type: text/html X-Powered-By: PHP/4.3.2 gethostbyname(www.imakenews.com) took 0.0010 s and resolved to 208.254.39.65br gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 63.87.252.162br gethostbyname(itpapers.zdnet.com) took 0.1922 s and resolved to 216.239.113.159br gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 63.87.252.162br but takes 20 seconds under Apache 2.0.46: gethostbyname(www.imakenews.com) took 5.0071 s and resolved to 208.254.39.65 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 63.87.252.162 gethostbyname(itpapers.zdnet.com) took 5.0097 s and resolved to 216.239.113.159 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 63.87.252.162 The DNS server timeout was set to 5 seconds, but we changed it to 10, and it had no effect on either. My efforts to Google this has not lead me in very helpful directions thus far, since gethostbyname() is not actually failing - it just takes 5 seconds to return. Even just a hint of where I might start looking will be much appreciated. Thanks, kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname() time issues
The following script: ?php $url_array = array( 'http://www.imakenews.com/progresspsdn/e_rss.aspx', 'http://rssnewsapps.ziffdavis.com/eweekdeveloper.xml', 'http://itpapers.zdnet.com/xml/RSS-239.xml', 'http://rssnewsapps.ziffdavis.com/eweeklinux.xml' ); foreach( $url_array as $url ) { $rdf = parse_url($url); $timestart = microtime(); $h = gethostbyname($rdf['host']); $timeend = microtime(); $diff = number_format(((substr($timeend,0,9)) + (substr($timeend,-10)) - (substr($timestart,0,9)) - (substr($timestart,-10))),4); This just looks wrong to me... at the very least shouldn't it be: (x + x) - (x + x) You've currently got the last + as a -. Also, why not split the result of microtime on a space in case $usec is more than 9 digits? echo gethostbyname(.$rdf['host'].) took $diff s and resolved to $hbr\n; } ? takes less than 1 second on CLI: # php gethostbyname.php Content-type: text/html X-Powered-By: PHP/4.3.2 gethostbyname(www.imakenews.com) took 0.0010 s and resolved to 208.254.39.65br gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 63.87.252.162br gethostbyname(itpapers.zdnet.com) took 0.1922 s and resolved to 216.239.113.159br gethostbyname(rssnewsapps.ziffdavis.com) took 0.0005 s and resolved to 63.87.252.162br but takes 20 seconds under Apache 2.0.46: gethostbyname(www.imakenews.com) took 5.0071 s and resolved to 208.254.39.65 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 63.87.252.162 gethostbyname(itpapers.zdnet.com) took 5.0097 s and resolved to 216.239.113.159 gethostbyname(rssnewsapps.ziffdavis.com) took 5.0099 s and resolved to 63.87.252.162 The DNS server timeout was set to 5 seconds, but we changed it to 10, and it had no effect on either. My efforts to Google this has not lead me in very helpful directions thus far, since gethostbyname() is not actually failing - it just takes 5 seconds to return. Even just a hint of where I might start looking will be much appreciated. Thanks, kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] gethostbyname() time issues
Philip Hallstrom wrote: $diff = number_format(((substr($timeend,0,9)) + (substr($timeend,-10)) - (substr($timestart,0,9)) - (substr($timestart,-10))),4); This just looks wrong to me... at the very least shouldn't it be: (x + x) - (x + x) (x + y) - (w + z) = (x + y) + (-w - z) = x + y - w - z Which is what I have. If you look closely, I don't have (x + x) - (x - x), which yes, would be wrong. You've currently got the last + as a -. Also, why not split the result of microtime on a space in case $usec is more than 9 digits? $usec is microseconds. I'm not really concerned about more than ten-thousandths of a second, so I don't even really need 9 digits. Conversly, I only need the seconds digits that are changing, and I can guarantee (hopefully) that my script is not taking so long that I need more than 10 digits to calculate the difference in seconds. It may be ridiculously convoluted code, I'll grant you that ;) - I took it from old script somewhere and didn't think of the looking in the manual for the much simpler example - but I'm pretty sure the math is fine. Anyways, I can assure you that it is too fast for me to count 1, 2, 3 CLI, but I get up to 20-something waiting for it to run under apache. Any ideas? kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GetHostByName
Hi all !!! I've made a PHP script which takes IP's of my network (x.x.x.2 - x.x.x.254) and then uses GetHostByName() to resolv names of the machines if they exist. (This is in order to check for free IP's and redo my DHCP config) But this only works for my own machine, because I filled my /etc/hosts with it's address and name... PHP (Or Linux) doesn't try to check outside What can i do ??? Do I have to lauch any kind of daemon to resolve names ??? Most of my machines are addressed by DHCP. Note : Same kind of program written with C++ returns Unknown Host Thanx, -- ( ° Nicolas Costes //\\ IUT de La Roche / Yon / \/ ) [EMAIL PROTECTED] '- http://luxregina.free.fr -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]