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
    Commented Jun 27, 2016 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
    Commented Jun 27, 2016 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
    Commented Jun 27, 2016 at 1:42

1 Answer 1


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .