• MikroTik.com
  • RouterBOARD
  • User Meeting
  • Training
  • User Manual
  • Support
  • Downloads
  • Videos
Register |   * Login | HOME

View unanswered posts | View active topics

NAT redirection to a local web server not working  Page 1 of 1
 [ 2 posts ]  Post new topic Reply to topic
  Print view Previous topic | Next topic 
Author Message
beepee
 Post subject: NAT redirection to a local web server not working
PostPosted: Fri Aug 26, 2011 5:55 pm 
Offline
Member Candidate
Member Candidate

Joined: Tue Sep 18, 2007 5:13 am
Posts: 130
Karma: 1
Hi guys
I have the ip address of some (hotspot) users stored in an address list and want to redirect then to the a local web server where they can check their details.
Actually those users are blacklisted users and I want them to be redirected to the local web server without seeing the hotspot login page.
What I have tried
When I tried this rule
Code:
ip firewall nat add chain=dstnat protocol=tcp src-address-list=Blacklisted action=dst-nat to-addresses=192.168.100.4 to-ports=80

it did not work, but when I replace the to-address with the router IP it worked but displaying the router webpage.
Question
Why did it not work for the local web server IP but worked for the router IP?
What am I suppose to do now?
I am stuck.

Thankx in adance.


Top
 Profile  
 
fewi
 Post subject: Re: NAT redirection to a local web server not working
PostPosted: Fri Aug 26, 2011 6:07 pm 
Offline
Forum Guru
Forum Guru

Joined: Tue Aug 11, 2009 2:19 am
Posts: 7737
Karma: 327
The Hotspot uses the dstnat chain as well - you can see the rules if you issue "/ip firewall nat print all", or in the manual: http://wiki.mikrotik.com/wiki/Manual:Customizing_Hotspot

You can't redirect users just like that because the Hotspot grabs the traffic first. You will have to use on the hook chains to redirect before that happens. RouterOS provides a 'pre-hotspot' custom chain that the Hotspot will execute before doing its own work. Shift your rule into that chain instead.

That said, you're redirecting all TCP traffic to a webserver. That's probably not the best of ideas. You should redirect HTTP only, and the firewal can identify that for you. An adjusted rule is below. Also, your web server has to be set up to pretend to be any web server in the world since clients will think they're talking to the real thing. That can be problematic. You may want to use the approach from http://wiki.mikrotik.com/wiki/Payment_Reminders instead, which uses the proxy to overcome that problem. Whether that's necessary depends on your web server.

Here the corrected rule:
Code:
/ip firewall nat
add chain=pre-hotspot hotspot=http src-address-list=Blacklisted action=dst-nat to-addresses=192.168.100.4


With the proxy approach it would look like this:
Code:
/ip proxy
set enabled=yes
set port=8081

/ip proxy access
add action=allow disabled=no dst-address=192.168.100.4
add action=deny disabled=no redirect-to="http://192.168.100.4/whatever.html"

/ip firewall nat
add chain=pre-hotspot hotspot=http src-address-list=Blacklisted action=redirect to-ports=8081

_________________
Specific answers require specific questions. When in doubt, post the output of "/ip address print detail", "/ip route print detail", "/interface print detail", "/ip firewall export", and an accurate network diagram.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 2 posts ] 

Board index » RouterOS » Forwarding Protocols

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Karma functions powered by Karma MOD © 2007, 2009 m157y