K
K
kAIST2015-03-29 14:26:18
linux
kAIST, 2015-03-29 14:26:18

How to redirect all sites to localhost?

There is an open wifi hotspot with debian (on raspberry pi).
It is required that when devices are connected, requests for port 80 are redirected to the local web server.
Something like how it is done when connecting to public access points, only easier - without authorization and without the ability to access the Internet.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2015-03-29
@kAIST

Replace foo_serverip with internal address

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -m conntrack --ctstate NEW -j DNAT --to foo_serverip:80
iptables -t nat -A PREROUTING -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

A
AVKor, 2015-03-29
@AVKor

iptables redirect to localhost?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question