Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm aware of other questions with the same topic, but I couldn't get it to work.

I'd like to forward inside my local network all traffic from ip1 to ip2. Only from inside the network, no outside.

I have a router with OpenWRT and I'd like to add an iptables inside the router. I'd like this forwarding being visible from any of the devices connected to my local network.

That means that from my computer (connected via wifi to the openwrt router) if I open a browser and type:, it is redirected to Both on port 80 and 3000 (and eventually others)

If I open I see my little http server.

I tried various combination of iptables via ssh to the OpenWRT router:

iptables -t nat -A PREROUTING -p tcp -d -j DNAT --to-destination
iptables -t nat -A OUTPUT -p tcp -d -j DNAT --to-destination

Nothing is working. In particular.. where can I see the logs?


I've also done it from the web panel luck in the OpenWRT. Seems correct to me: enter image description here

Of course there is nothing at (I meant it as a virtual fixed ip)

share|improve this question
Why is it not an option to use in any place that you would otherwise use – Robbie Mckennie Jun 17 '14 at 12:49 is actually dynamic: from DHCP. should a static IP. So that: each time the embedded system that now is at is on sends a message to the router and the router set the iptable to redirect. This is a workaround because I haven't managed to set the embedded device with a static ip... – nkint Jun 17 '14 at 12:52
It seems to me that it would be a lot easier to give a static ip that to redirect traffic to a dynamic ip. I'm no expert on OpenWRT, but I know that this is trivial to do in a more generic set up by editing dhcpd.conf – Robbie Mckennie Jun 17 '14 at 12:57
how to do it? I mean: I need to have a static ip for a specific MAC address without touching the embedded device.. – nkint Jun 17 '14 at 13:03
I don't know how to do it under OpenWRT, but this page has a section for static ip allocation: I'd refer you to that. – Robbie Mckennie Jun 17 '14 at 13:16

As you described it, this can't be done with iptables from your router. iptables only operates on packets being routed through your router (good name, huh?). Packets that going between 2 hosts on the same physical network have all their routing down by hosts themselves; no need for going through your router.

If doesn't actually exist, you could potentially give a second 'alias' ip address. Or even give some third machine the alias ip, and forward traffic from it to

share|improve this answer
I need to do it for all devices connected to my local network (see the edits) – nkint Jun 17 '14 at 12:37
@nkint What OS is running? – Robbie Mckennie Jun 17 '14 at 12:40
alias seems nice: so the machine that is at has actually 2 ip: (the real one) and (the aliased one). How to do it? – nkint Jun 17 '14 at 12:40
another openWRT inside an embedded device BUT I don't want to touch it (I tried to do it but I made some messy works and nothing was working so I'd like to do it on the router side only. Much more safe) – nkint Jun 17 '14 at 12:42
@nkint The only way to give a host an alias to to change the configuration on that host itself – Robbie Mckennie Jun 17 '14 at 12:43

You must log in to answer this question.

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