forwarding requests to another ip using IPTABLES
I am trying to forward packets coming to one ip address(say 192.168.1.222 port 4080) to another ip address (say 192.168.1.118).
I tried the following rule:
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.222 --dport 4080 -j DNAT --to-destination 192.168.1.118
But it did not work. I also observed that,
iptables -t nat -A PREROUTING -p tcp -d 192.168.1.118 --dport 4080 -j DNAT --to-destination 192.168.1.118:4088
works, i.e, port redirection works.
I tried out google and also read a couple of tutorials but unfortuately I am still unable to find the problem.
I am using Red Hat 8 on both the computers.
Can any one point me to the right direction?