Getting IP address
Moderator: General Moderators
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Getting IP address
How can I print my system's local IP address in browser?
I tried the below methods and I did not get that.
print_r($_SERVER);
print "<br><br>";
print_r( $HTTP_SERVER_VARS);
I tried the below methods and I did not get that.
print_r($_SERVER);
print "<br><br>";
print_r( $HTTP_SERVER_VARS);
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Re: Getting IP address
I tried this and it is printing,
print "IP :: ".$_SERVER['SERVER_ADDR'];
IP :: 192.168.1.12
But my local IP address is in 192.168.8.102 .
print "IP :: ".$_SERVER['SERVER_ADDR'];
IP :: 192.168.1.12
But my local IP address is in 192.168.8.102 .
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Re: Getting IP address
I tried both the methods,
print "IP :: ".$_SERVER['SERVER_ADDR'];
print "IP1 :: ".$_SERVER['REMOTE_ADDR'];
It prints the result as,
IP :: 192.168.1.12
IP1 :: 192.168.1.10
It's not my system's local IP (192.168.8.102).
print "IP :: ".$_SERVER['SERVER_ADDR'];
print "IP1 :: ".$_SERVER['REMOTE_ADDR'];
It prints the result as,
IP :: 192.168.1.12
IP1 :: 192.168.1.10
It's not my system's local IP (192.168.8.102).
Re: Getting IP address
$_SERVER['LOCAL_ADDR'] ?
There are 10 types of people in this world, those who understand binary and those who don't
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Re: Getting IP address
It doesn't print anything to me.
$_SERVER['LOCAL_ADDR']
$_SERVER['LOCAL_ADDR']
Re: Getting IP address
Is it Windows (version) or Linux?
There are 10 types of people in this world, those who understand binary and those who don't
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Re: Getting IP address
It is linux system
Linux version 2.6.26-2-686 (Debian 2.6.26-17lenny2) (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Fri Aug 14 01:27:18 UTC 2009
Linux version 2.6.26-2-686 (Debian 2.6.26-17lenny2) (dannf@debian.org) (gcc version 4.1.3 20080704 (prerelease) (Debian 4.1.2-25)) #1 SMP Fri Aug 14 01:27:18 UTC 2009
Re: Getting IP address
What's the output of:
?
Code: Select all
ifconfigThere are 10 types of people in this world, those who understand binary and those who don't
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Re: Getting IP address
/sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:1D:92:DE:49:9B
inet addr:192.168.8.20 Bcast:192.168.8.255 Mask:255.255.255.0
inet6 addr: fe80::21d:92ff:fede:499b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4281176819 errors:0 dropped:3002 overruns:0 frame:0
TX packets:295399131 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1770624014 (1.6 GiB) TX bytes:2600959972 (2.4 GiB)
Interrupt:23 Base address:0xdc00
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3520722 errors:0 dropped:0 overruns:0 frame:0
TX packets:3520722 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1208552913 (1.1 GiB) TX bytes:1208552913 (1.1 GiB)
eth0 Link encap:Ethernet HWaddr 00:1D:92:DE:49:9B
inet addr:192.168.8.20 Bcast:192.168.8.255 Mask:255.255.255.0
inet6 addr: fe80::21d:92ff:fede:499b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4281176819 errors:0 dropped:3002 overruns:0 frame:0
TX packets:295399131 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1770624014 (1.6 GiB) TX bytes:2600959972 (2.4 GiB)
Interrupt:23 Base address:0xdc00
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3520722 errors:0 dropped:0 overruns:0 frame:0
TX packets:3520722 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1208552913 (1.1 GiB) TX bytes:1208552913 (1.1 GiB)
Re: Getting IP address
192.168.1.12/192.168.1.10 and 192.168.8.102 seem to be in different network segments.
Are you sure there isn't a router between your PC (192.168.1.10), which masks (DMZ, SNAT or port forwarding) the web server IP address (192.168.8.102) by replacing it with its own IP address - 192.168.1.12 ?
PS:
Never mind, I think the $_SERVER['SERVER_ADDR'] has nothing to do with it ...
Strange...
Are you sure there isn't a router between your PC (192.168.1.10), which masks (DMZ, SNAT or port forwarding) the web server IP address (192.168.8.102) by replacing it with its own IP address - 192.168.1.12 ?
PS:
Strange...
There are 10 types of people in this world, those who understand binary and those who don't
Re: Getting IP address
Code: Select all
echo gethostbyname($_SERVER['SERVER_NAME']);There are 10 types of people in this world, those who understand binary and those who don't
-
manoj_hicool
- Forum Newbie
- Posts: 9
- Joined: Mon Mar 08, 2010 1:22 am
Re: Getting IP address
It prints the IP as,
echo gethostbyname($_SERVER['SERVER_NAME']);
192.168.1.12
echo gethostbyname($_SERVER['SERVER_NAME']);
192.168.1.12