Community discussions

MikroTik App
 
zimbola
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Mon Feb 16, 2015 5:02 pm

IP address shows routers ip instead of users

Wed Apr 22, 2015 8:15 am

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
 
dada
Member Candidate
Member Candidate
Posts: 245
Joined: Tue Feb 21, 2006 1:44 pm

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 8:36 am

Hi,

are you using a proxy or some strange NAT scenario?

And how the problem is related to Mikrotik ??
 
zimbola
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Mon Feb 16, 2015 5:02 pm

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 8:39 am

Nope, I'm not using proxy.
My scenario is some what similar to http://superuser.com/questions/677068/s ... router-for
It's actually not a MikroTik Problem. I just am not able to configure it the way i want.
Thanks
 
User avatar
Stillhard
Frequent Visitor
Frequent Visitor
Posts: 82
Joined: Sun Jun 10, 2012 11:18 am
Location: Banten, Indonesia
Contact:

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 8:41 am

Use HAIRPIN 8)
 
dada
Member Candidate
Member Candidate
Posts: 245
Joined: Tue Feb 21, 2006 1:44 pm

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 9:39 am

Nope, I'm not using proxy.
My scenario is some what similar to http://superuser.com/questions/677068/s ... router-for
It's actually not a MikroTik Problem. I just am not able to configure it the way i want.
Thanks
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.
 
zimbola
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Mon Feb 16, 2015 5:02 pm

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 9:44 am

Nope, I'm not using proxy.
My scenario is some what similar to http://superuser.com/questions/677068/s ... router-for
It's actually not a MikroTik Problem. I just am not able to configure it the way i want.
Thanks
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
 
zimbola
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Mon Feb 16, 2015 5:02 pm

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 9:52 am

Use HAIRPIN 8)
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
 
zimbola
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Mon Feb 16, 2015 5:02 pm

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 3:06 pm

Finally solved the issue following this link --> https://yaleman.org/2014/10/23/hairpin- ... tik-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 :)
 
User avatar
Stillhard
Frequent Visitor
Frequent Visitor
Posts: 82
Joined: Sun Jun 10, 2012 11:18 am
Location: Banten, Indonesia
Contact:

Re: IP address shows routers ip instead of users

Wed Apr 22, 2015 3:28 pm

Finally solved the issue following this link --> https://yaleman.org/2014/10/23/hairpin- ... tik-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 :)
You're welcome m8 8)
Edited: thank you for the good karma :D

Who is online

Users browsing this forum: No registered users and 77 guests