How to do the port forwarding from one ip to another ip in same network?

These rules should work, assuming that iptables is running on server 192.168.12.87 : #!/bin/sh echo 1 > /proc/sys/net/ipv4/ip_forward iptables -F iptables -t nat -F iptables -X iptables -t nat -A PREROUTING -p tcp –dport 80 -j DNAT –to-destination 192.168.12.77:80 iptables -t nat -A POSTROUTING -p tcp -d 192.168.12.77 –dport 80 -j SNAT –to-source 192.168.12.87 You … Read more

How can I port forward with iptables?

First of all – you should check if forwarding is allowed at all: cat /proc/sys/net/ipv4/conf/ppp0/forwarding cat /proc/sys/net/ipv4/conf/eth0/forwarding If both returns 1 it’s ok. If not do the following: echo ‘1’ | sudo tee /proc/sys/net/ipv4/conf/ppp0/forwarding echo ‘1’ | sudo tee /proc/sys/net/ipv4/conf/eth0/forwarding Second thing – DNAT could be applied on nat table only. So, your rule should … Read more