I created the rule

sudo iptables -t nat -A OUTPUT -d -j DNAT --to-destination

Then, when I acess the site, instead of execute the normal page of this site, it will execute a script in my computer and return it. It's work. But, if I to create a hotspot in my computer and going to this site using my cellphone, this will not work. Execute a normal page of this site.

Why? How to fix it, to working in my cellphone.

  • use PREROUTING instead OUTPUT
    – Baba
    Jun 27 '16 at 1:21
  • @Babyy I tried using PREROUTING, but, not working. The cellphone can't load the page. Well... I think that I need use -t filter instead of -t nat, rigth? i.imgur.com/ufLpSqz.png
    – Macabeus
    Jun 27 '16 at 1:30
  • @Babyy But table filter can't use DNAT. I receive the error message "x_tables: ip_tables: DNAT target: only valid in nat table, not filter".
    – Macabeus
    Jun 27 '16 at 1:42

I resolved my problem.

sudo iptables -t nat -A PREROUTING -d -j DNAT --to

I need use instead of, becuse, for my cellphone, the hotspot's script is located in, not in localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.