Complete iptables Shell Scripts
- Drop all iptables rules.(Handy for flushing everything when you are working on new iptables rules.)
- A simple, safe, understandable iptables script.(Use this for a desktop linux box that serves nothing.)
- The above script, but allowing ssh traffic in.
- A more complicated script, appropriate for a server.
Allow Tomcat to Run as Unpriveledged User But Still Serve Port 80
iptables --table nat --append PREROUTING --protocol tcp --destination-port 80 \ --in-interface eth0 --jump REDIRECT --to-port 8080
NOTE!The above rule will not redirect local requests, since these bypass the PREROUTING chain. Any browsers or other client software running on the server itself will either have to connect directly to port 8080. In most situations, this will be acceptable.