I have a vhost on my webserver whose sole and unique goal is to return the client IP adress:
[email protected]:~$ cat /home/vhosts/domain.org/index.php
<?php echo $_SERVER['REMOTE_ADDR']; echo "\n" ?>
This helps me troubleshoot networking issues, especially when NAT is involved. As such, I don't always have domain name resolution and this service needs to work even if queried by its IP address.
I'm using it this way:
[email protected]:~$ echo "GET /" | nc 88.191.124.41 80
191.51.4.55
[email protected]:~$ echo "GET /" | nc domain.org 80
191.51.4.55
router#more http://88.191.124.41/index.php
88.191.124.254
However I found that it wasn't working from at least a computer:
[email protected]:~$ echo "GET /" | nc domain.org 80
[email protected]:~$
[email protected]:~$ echo "GET /" | nc 88.191.124.41 80
[email protected]:~$
What I checked:
This is not related to ipv6:
[email protected]:~$ echo "GET /" | nc -4 ydct.org 80
[email protected]:~$
[email protected]:~$ echo "GET /" | nc ydct.org 80
2a01:e35:ee8c:180:21c:77ff:fe30:9e36
netcat version is the same (except platform, i386 vs x64):
[email protected]:~$ type nc
nc est haché (/bin/nc)
pe
[email protected]:~$ file /bin/nc
/bin/nc: symbolic link to `/etc/alternatives/nc'
[email protected]:~$ ls -l /etc/alternatives/nc
lrwxrwxrwx 1 root root 15 2010-06-26 14:01 /etc/alternatives/nc -> /bin/nc.openbsd
[email protected]:~$ type nc
nc est haché (/bin/nc)
[email protected]:~$ file /bin/nc
/bin/nc: symbolic link to `/etc/alternatives/nc'
[email protected]:~$ ls -l /etc/alternatives/nc
lrwxrwxrwx 1 root root 15 2011-05-26 01:23 /etc/alternatives/nc -> /bin/nc.openbsd
It works when used without the pipe:
[email protected]:~$ nc domain.org 80
GET /
2a01:e35:ee8c:180:221:85ff:fe96:e485
And the piping works at least with a test service (netcat listening on 1234/tcp and output to stdout)
[email protected]:~$ nc -l -p 1234
GET /
[email protected]:~$
[email protected]:~$ echo "GET /" | nc domain.org 1234
[email protected]:~$
I don't know if this issue is more related to netcat or Apache, but I'd appreciate any pointers to troubleshoot this issue !
The IP addresses have been modified but kept consistent for easy
reading. bzn is the server, hive is a working client and
seth is the
client on which I have the issue.