goldensona — 2011-09-04T08:19:39-04:00 — #1
i want to retrieve the server ip address, i have used this code for getting server ip address
this return local ip address instead of the displaying ip address in the url.
why ? can any one tell the reason.. to solve this
if the url contain the 12... means it return local 10...
i want 12.. .
goldensona — 2011-09-07T05:46:01-04:00 — #2
Thanks for your answer deathshadow60. i will try this approach.
that is the ip address assign by some isp provider like if we go to What Is My IP Address? Lookup IP, Hide IP, Change IP, Trace IP and more... it will show the ip address provided by isp. my local ip 10.0...... if i run my script under my local ip it return 10.0..... i want to return ip address provided by isp.
system — 2011-09-07T06:25:31-04:00 — #3
That statement still makes no sense... I'm wondering if we have a terminology issue or something here. What do you mean "run it on my local IP"? Are you talking a local server like XAMPP or something? Something on your WAN that isn't exposed on the other side of your router?
Either 1) you have the most bizzare hardware setup I've ever heard of, 2) you're failing to grasp how this stuff works -- or 3) I'm COMPLETELY missing your meaning entirely.
system — 2011-09-07T02:05:55-04:00 — #4
Wait, are you saying the public IP address isn't the one the server is at? that's screwy... behind a home router or something?
If you are accepting requests by IP address, you could always pull it from REQUEST_URI instead.
$domainPath should then be either the IP address OR the domain name depending on the request type . If you NEED the IP address, test if it's a valid IP addy (another explode and four is_numeric?), if it isn't, then call gethostbyname.
goldensona — 2011-09-07T01:06:26-04:00 — #5
that is i need the public ip address of the server ?how do i get it can anyone help me
goldensona — 2011-09-06T03:14:41-04:00 — #6
thank you for your reply
gethostbyname is work when we know domain name. if the url contiains 123.... how to i get ip address =123....
if i use $SERVER['REMOTEADDR'] it will return local ip of the system, i want ipaddress which is displaying in the url bar
logic_earth — 2011-09-06T02:53:42-04:00 — #7
goldensona — 2011-09-06T01:11:56-04:00 — #8
yes i want the domain name ip address how to i get it?
logic_earth — 2011-09-04T16:25:57-04:00 — #9
You are getting a local IP address because you are connecting to the server from a local IP address.
I assume you are wanting the IP address of your domain name, correct?
system — 2011-09-04T14:31:01-04:00 — #10
Huh? "in the url"?
Could you explain better? I can't even make sense out of your post.
SERVER_ADDR should be giving you the IP address of wherever that PHP code is being run -- aka the server it's being run from/on, not the client... The phrase "IP address in the URL" makes no sense whatsoever....well, unless you're calling the IP addy instead of by domain name...