IP address shows routers ip instead of users

Greetings friends.
I have setup a internal web server for testing purpose.
and have a .php script that should display the ip address of the client that accessed the page
IP address shows routers ip instead of users

<?php
$ipadress = $_SERVER['REMOTE_ADDR'];
echo "Your IP Address is $ipadress";
<?

Instead of showing the IP Address of the client it is showing the router’s IP Address. 192.168.3.1

Flags: X - disabled, I - invalid, D - dynamic

ADDRESS NETWORK INTERFACE

1 192.168.6.1/24 192.168.6.0 wlan1
2 192.168.2.1/24 192.168.2.0 e2-LAN
3 192.168.3.1/24 192.168.3.0 e3-WS
4 D182.xx.xx.xx/32 182.xx.xx.xx ppp

Either from Inside LAN or from Outside World it’s showing the IP Address of the router interface.
Is there any way i can show the real IP of clients accessing the Web server via PHP Script.
Thanks

Hi,

are you using a proxy or some strange NAT scenario?

And how the problem is related to Mikrotik ??

Nope, I’m not using proxy.
My scenario is some what similar to http://superuser.com/questions/677068/server-remote-ip-always-returns-ip-address-of-the-default-gateway-router-for
It’s actually not a MikroTik Problem. I just am not able to configure it the way i want.
Thanks

Use HAIRPIN :sunglasses:

I can understand the local LAN IP problem - somehow your LAN computers are accessing the WEB server through your NAT router (which translates source IP address off all packets which forward on 192.168.3 IP address). It could happen if you WEB server is from other subnet than the station connection to it. The solution is (as mentioned by Stillhard) to configure the NAT so it will be translate packets only when they will be sent to the Internet side.

If you see the bad IP even on requests sent from Internet = mayby your NAT translates these requests too.

Yes you’re right.
My Test Web Server is on 192.168.3.0/24
and i’m accessing it from 192.168.6.0/24
Thanks

Yes I looked HAIRPIN nat after you mentioned but i’m not quite sure either it will solve my problem or not
in the link http://wiki.mikrotik.com/wiki/Hairpin_NAT some where it is written as below.

There is no way to avoid this without either using a router that can do application level DNS inspection and can rewrite A records accordingly, or a split DNS server that serves the internal clients

It is not that i’m unable to access the web server either from external internet or local lan.
The problem is Web Server thinks that i’m accessing the page from 192.168.3.1 so my php script always displays the accessing IP Address as 192.168.3.1 and not of the internal client IP or external IP Address of computers accessing the webserver

WILL HAIRPIN help me in this scenario.. ??
Thanks

Finally solved the issue following this link → https://yaleman.org/2014/10/23/hairpin-nat-on-mikrotik-v6-19/
Special Thanks to StillHard for giving hint as HAIRPIN. I was totally lost before as what the search string should be for my problem.
Have a wonderful day friends :slight_smile:

You’re welcome m8 :sunglasses:
Edited: thank you for the good karma :smiley: