How to obtain the IP of the requesting server

Source: Internet
Author: User
I have a.php on a server, and then use the b.php on the B server to a.php, how to let a.php know the IP address of B, thank you


Reply to discussion (solution)

$_server[' REMOTE_ADDR ') gets the IP of the requester

$_server[' REMOTE_ADDR ') gets the IP of the requester
Tried this only to take the IP of the computer currently open the browser, my request is the program in the background hair

How do you ask for b.php?

How do you ask for b.php?
File_get_contents

GetHostByName gets the IP address of the specified Internet host name
Cases:
echo gethostbyname (' bbs.csdn.net '); 117.79.157.198

GetHostByName gets the IP address of the specified Internet host name
Cases:
echo gethostbyname (' bbs.csdn.net '); 117.79.157.198
I want to only let the specified host IP access, you can only get a certain IP, but I do not know which server is the other one to submit the request

I have a.php on a server, and then use the b.php on the B server to a.php, how to let a.php know the IP address of B, thank you
$_SERVER[SERVER_ADDR]


I have a.php on a server, and then use the b.php on the B server to a.php, how to let a.php know the IP address of B, thank you
$_SERVER[SERVER_ADDR]
This is the B server's IP ah, I want to take a service

This post was last edited by xuzuning on 2013-07-01 16:01:52

#0: How to let a.php know the IP address of b
#8: or b server's IP ah, I want to take a service

If you think about it first, ask again!

#0: How to let a.php know the IP address of b
#8: or b server's IP ah, I want to take a service

If you think about it first, ask again!
I'm sorry I made a mistake three days ago. The address of A to take b = = $_server[server_addr] The above method should be established in the case of B server to pass IP to a, but the other party can pass the value of FALSE

Why not the IP that was obtained with gethostbyname?

Why not the IP that was obtained with gethostbyname?
I am a top-up platform, I want to prevent the partner private access, so it is necessary to specify the whitelist only the white list of IP requests valid, so.

The gethostbyname parameter is the domain name, and the IP of the corresponding host is returned.
If this is not true, then I have no words.

The gethostbyname parameter is the domain name, and the IP of the corresponding host is returned.
If this is not true, then I have no words.
This is credible, not the reason for this is that I know that a certain IP is our partner, but if the third party intervention, I do not know his domain name and do not know his IP can not be judged


How do you ask for b.php?
File_get_contents I neither know his domain nor know his IP
Then how do you file_get_contents?



How do you ask for b.php?
File_get_contents I neither know his domain nor know his IP
Then how do you file_get_contents?
This sentence is written on the B server, this server is not mine, so if you rely on his value can not be sure of true and false, to get B from my own server a request address.

Pro, file_get_contents can get the address of B on a machine, this function can also be used to determine whether a domain name is really present

It's wrong, it's the gethostbyname function.

Above said wrong, is gethostbyname function This function premise is you want to know each other's domain Ah, now I do not know the requester's domain name

That's usually the remote_addr,http_x_forwarded_for,http_client_ip,http_x_forwarded_for of the $_server variable.

That is generally to see the $_server variable remote_addr,http_x_forwarded_for,http_client_ip,http_x_forwarded_for These parameters so that the use of which ... I'm not very familiar.

Continue to beg ...

Good... Find out why, thanks, everybody upstairs.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.