How to obtain the IP address of the request server

Source: Internet
Author: User
How can I obtain the IP address of the request server. php, and then use B. input parameters to. php, how to make. php knows the IP address of B. thank you.


Reply to discussion (solution)

$ _ SERVER ['remote _ ADDR '] obtains the IP address of the requester.

$ _ SERVER ['remote _ ADDR '] obtains the IP address of the requester.
I tried to use the IP address of the computer where the browser is currently opened. my request is sent by the program in the background.

How do you request B. php?

How do you request B. php?
File_get_contents

Gethostbyname: get the IP address of the specified Internet host name.
Example:
Echo gethostbyname ('bbs .csdn.net '); // 117.79.157.198

Gethostbyname: get the IP address of the specified Internet host name.
Example:
Echo gethostbyname ('bbs .csdn.net '); // 117.79.157.198
I want to only access the specified host IP address. in this way, you can only obtain one IP address, but I don't know which server the other server is submitting an application.

I have A. php on server a, and then use B. php on server B to pass the parameter to a. php. how can I let a. php know the IP address of B? thank you.
$ _ SERVER [SERVER_ADDR]


I have A. php on server a, and then use B. php on server B to pass the parameter to a. php. how can I let a. php know the IP address of B? thank you.
$ _ SERVER [SERVER_ADDR]
This is the IP address of server B. I want to use service.

This post was last edited by xuzuning at 16:01:52

#0: How to let a. php know the IP address of B
#8: Still the IP address of server B. I want to obtain service.

Ask a question first!

#0: How to let a. php know the IP address of B
#8: Still the IP address of server B. I want to obtain service.

Ask a question first!
Sorry, I got it wrong three days later. it is the method above that A wants to get B's address == _ SERVER [SERVER_ADDR]. it is successful only when server B passes the IP address to, however, the opposite party can pass false values.

Why can't I use the ip address obtained by gethostbyname?

Why can't I use the ip address obtained by gethostbyname?
I am a recharge platform. in order to prevent private access from partners, it is necessary to stipulate that only IP requests in the whitelist are valid ..

The gethostbyname parameter is the domain name and returns the ip address of the corresponding host.
If I cannot even trust this, I will be speechless.

The gethostbyname parameter is the domain name and returns the ip address of the corresponding host.
If I cannot even trust this, I will be speechless.
This is credible. I don't need this because I know that an IP address must be our partner, however, if a third party is involved, I cannot determine whether his domain name or IP address is known.


How do you request B. php?
File_get_contents I neither know his domain name nor his IP address
Then how do you file_get_contents?



How do you request B. php?
File_get_contents I neither know his domain name nor his IP address
Then how do you file_get_contents?
This sentence is written on server B. This server is not mine. Therefore, if the value is passed by another server, it cannot be determined whether it is true or false. you must obtain the request address of server B from server.

File_get_contents can obtain the address of B on machine A. This function can also be used to determine whether A domain name actually exists.

The above is incorrect. it is the gethostbyname function.

The above is wrong. it is the gethostbyname function. The premise is that you need to know the domain name of the other party. now I do not know the domain name of the requester.

Generally, the REMOTE_ADDR, HTTP_X_FORWARDED_FOR, HTTP_CLIENT_IP, and HTTP_X_FORWARDED_FOR parameters of the $ _ SERVER variable are used.

In general, the REMOTE_ADDR, HTTP_X_FORWARDED_FOR, HTTP_CLIENT_IP, and HTTP_X_FORWARDED_FOR parameters of the $ _ SERVER variable are used... I am not very familiar

Continue to seek ......

Okay... Find the reason. thank you.

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.