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: 192.168.1.42, it is redirected to 192.168.1.198. Both on port 80 and 3000 (and eventually others)
If I open 192.168.1.198 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 192.168.1.42 -j DNAT --to-destination 192.168.1.198 iptables -t nat -A OUTPUT -p tcp -d 192.168.1.42 -j DNAT --to-destination 192.168.1.198
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:
Of course there is nothing at 192.168.1.42 (I meant it as a virtual fixed ip)