I have a Linux machine in my local network that I use as a gateway, so all of my network traffic passes it (the machine has only one network interface which I use for incoming and outgoing traffic). I need to forward all HTTP packages coming in on port 7080 to port 80. Furthermore I want to redirect the HTTP responses back to the client that sent the request.
I tried to achieve that using the following iptables rules:
iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 7080 -j ACCEPT iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT iptables -t nat -A OUTPUT -p tcp --dport 7080 -j REDIRECT --to-ports 80 iptables -t nat -A OUTPUT -p tcp --dport 80 -j REDIRECT --to-ports 7080
When those rules are active I do not receive any HTTP responses on a client.
Does anybody have an idea what I am doing wrong, or how I could solve this problem?