Ubuntu: Redirect iptables to apache without internet connection


I have set up a Personal hotspot using Hostapd. But this hotspot is not connected to the internet but I do have Apache installed on it. What I am trying to achieve is to redirect all the clients (that are connected to my hotspot) to my apache page when they visit another website. So basically redirect all traffic to my Apache page.

What I have tried is :

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination  

But with this iptable the clients only get redirected to my Apache webpage when I share an internet connection with my hotspot. But without the internet connection they do not get redirected.

Also tried:

sudo iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination  


Impressive as it was not established where the traffic comes.

-s IP  -i Interface  


sudo iptables -t nat -A PREROUTING -s -p tcp --dport 80 -j DNAT --to-destination    sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j DNAT --to-destination  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »