Community discussions

MikroTik App
 
User avatar
kyatera
just joined
Topic Author
Posts: 2
Joined: Mon Mar 28, 2011 12:35 am
Location: Campinas-SP-Brazil
Contact:

Redirect without hotspot

Mon Mar 28, 2011 12:40 am

Mikrotik configured my OS as follows:

/ Ip firewall nat
add action = src-nat chain = srcnat comment = "" disabled = no src-address = 192.168.1.83 to-addresses = 188.132.227.1

There 192.168.1.83 as direct the user to a particular site without using the hotspot just NAT?

Thanks
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Redirect without hotspot

Mon Mar 28, 2011 1:38 am

You can use destination NAT (not source NAT) to rewrite the destination IP address of a packet a client sends to a server. Whatever you send the altered packet to will have to be able to cope with requests for resources it doesn't have. This is functionality on layer three of the OSI model.

Hotspots and proxies can do true redirects on layer seven of the OSI model and are assisted by destination NAT. First destination NAT is used to rewrite the packet so that it is sent to the Hotspot or proxy. That service then accepts the packet and issues an HTTP redirect either via the appropriate status code indicating to the client that the requested resource has moved together with the new location, or by serving the requested resource in such a fashion that the client then requests a different resource immediately - usually a meta refresh or JavaScript.

The latter works better without a specially programmed web server. If you only use NAT the web server would get the exact request the original server would have gotten. If a client asks yahoo.com for this.html, and the packet is rewritten by destination NAT to a different server, that server will still be asked for this.html. It likely won't have that resource and respond with an error (404 not found).
 
blake
Member
Member
Posts: 426
Joined: Mon May 31, 2010 10:46 pm
Location: Arizona

Re: Redirect without hotspot

Mon Mar 28, 2011 3:59 am

How about this?
/ip firewall nat
add chain=dstnat src-address=192.168.1.83 protocol=tcp dst-port=80 action=redirect to-ports=8080

/ip proxy
set enabled=yes port=8080

/ip proxy access
add dst-port=80 action=allow dst-host="188.132.227.1"
add dst-port=80 action=deny redirect-to="188.132.227.1"
You'll want to replace the occurrences of 188.132.227.1 under '/ip proxy access' the actual website hostname. When the user tries to visit any other site they will be automatically redirected to the site you specify.
 
User avatar
kyatera
just joined
Topic Author
Posts: 2
Joined: Mon Mar 28, 2011 12:35 am
Location: Campinas-SP-Brazil
Contact:

Re: Redirect without hotspot

Mon Mar 28, 2011 2:54 pm

Good idea
I will try and post the result.
Thanks for the quick response.

Who is online

Users browsing this forum: No registered users and 18 guests