iptables PREROUTING rule doesn't work from localhost

Solution Verified - Updated -

Issue

  • Cannot connect from local host to https after configuring ipforwarding.
  • Configured port forwarding using iptables from 80 to 8080 . Port redirection works when it is accessed from other hosts,  but when logged in to the system locally, port redirection doesn't work.
  • iptables port forwarding from localhost to a different port doesn't work.
  • An iptables rule to to redirect all traffic from <virtual IP>:80 to <virtual IP>:1024 works when accessed from external hosts.  However when the traffic is coming from another application on the same host, it does not work (access to the listening application is denied)

Environment

  • Red Hat Enterprise Linux (all versions)
  • iptables, with a PREROUTING rule such as:

    -A PREROUTING -d 192.168.143.123 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.143.123:1024 
    

OR:

-A PREROUTING   -m tcp -p tcp --dport 80 -j REDIRECT --to-ports 8080

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content