| | |
Server Address vs DNS
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2009
Posts: 3
Reputation:
Solved Threads: 0
I have some code that is called from with other files, using readfile so there is no referer etc.
To authenticate that the request is where it should be from, the php is passed a calling url as part of it parameters.
The idea is that I can then check the calling IP is from the correct machine. This works fine in most cases, however on some machines (I'm guessing VPS) the Server address is not what the DNS returns even though the domain name is hosted on that PC.
Here is my code.
In theory the REMOTE_ADDR and the IP returned from gethostbyname should match but they don't anybody any ideas how to get round this?
To authenticate that the request is where it should be from, the php is passed a calling url as part of it parameters.
The idea is that I can then check the calling IP is from the correct machine. This works fine in most cases, however on some machines (I'm guessing VPS) the Server address is not what the DNS returns even though the domain name is hosted on that PC.
Here is my code.
PHP Syntax (Toggle Plain Text)
$ip = gethostbyname($domain); if ($ip != $_SERVER["REMOTE_ADDR"]) { echo "URL does not match requesting IP address<br>\n"; echo "$domain - $ip<br>\n"; echo $_SERVER["REMOTE_ADDR"]."<br>\n"; exit; }
In theory the REMOTE_ADDR and the IP returned from gethostbyname should match but they don't anybody any ideas how to get round this?
Last edited by finance-blog; Jan 2nd, 2009 at 4:02 pm.
•
•
Join Date: Dec 2007
Posts: 19
Reputation:
Solved Threads: 4
try these line and see what you get?
best of luck with the job.
php Syntax (Toggle Plain Text)
<?php $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']) ; ?>
best of luck with the job.
Last edited by peter_budo; Jan 6th, 2009 at 2:14 pm. Reason: Code tag correction please [code=php] instead of [code syntax="php"]
abdoolherkym!
The domain probably has more then one IP.
Try:
http://www.php.net/manual/en/functio...ostbynamel.php
and do a in_array() on the list of IPs.
http://www.php.net/in_array
Try:
http://www.php.net/manual/en/functio...ostbynamel.php
and do a in_array() on the list of IPs.
http://www.php.net/in_array
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- DNS Error. . . (Viruses, Spyware and other Nasties)
- internet explorer not working (Windows 95 / 98 / Me)
- DNS server (Domains and DNS)
- NETGEAR wireless router with Windows 2000 server gateway help! (Networking Hardware Configuration)
- accessing a novel server from a remote location (Novell)
- ip address setup (Windows NT / 2000 / XP)
- need help adding a registered domain name to my IIS server... (Windows Servers and IIS)
- Browser Settings - www point to local host Server (Windows NT / 2000 / XP)
- cannot find server - Microsoft Internet Explorer afterdownloading Win Service pack 2 (Networking Hardware Configuration)
- DNS error - please advise on HiJack log (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Drupal Menus
- Next Thread: Call Home Function (Like paid scripts have)
| Thread Tools | Search this Thread |
.htaccess alerts apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code convert cron curl database dataentry date display duplicates dynamic echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google hack href htaccess html htmlspecialchars image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching menu methods mlm multiple mysql network object oop paypal pdf php problem query radio random recursion recursive redirect remote script search securephp server sessions shot sms source space sql subscription syntax system table tutorial tutorials update upload url validator variable video web youtube






