Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Im currently using ufw to enforce some basic firewall rules. Is it possible to also use ufw to do port forwarding?

Specifically im wanting to forward incoming traffic to my server (same machine running ufw) on port 80 to port 8080. (http traffic forwarded to tomcat)


share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

Add before filter section in /etc/ufw/before.rules(top of file):

-A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Then restart ufw.

share|improve this answer
could you explain this line by line please? also, is there not something like ufw forward 80 to 8080? I thought UFW was Uncomplicated. –  Tom Mar 11 '12 at 11:58
Looks like there are no ufw commands for setting up the port fowards, so it must be done via configuraton files. More detailed description about the configuration file syntax is available at: frozentux.net/iptables-tutorial/… –  Juha Palomäki Jul 24 '12 at 9:01
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.