I have two interfaces eth0 ( and eth1 (

I receive data from 8080 at eth0. I want to forward it to eth1 port 80.

I'm using UFW, because i don't understand iptables and how to add it at the beggining of /etc/ufw/before.rules.

I've already edited DEFAULT_FORWARD_POLICY="ACCEPT" on /etc/default/ufw and already edited net.ipv4.ip_forward=1 on /etc/ufw/sysctl.conf

  • So there's a service running on eth1 port 80, and you want it to accept connections on eth0 port 8080? – davidbaumann Dec 8 '15 at 19:25
  • people connect to eth0 8080, but the server is at eth1 80. I want to redirect or forward the data so they can see my server. – sergius Dec 8 '15 at 19:47
  • Imho, if you are in control of that service, it should be better to configure the service, instead of doing this workaround... – davidbaumann Dec 8 '15 at 19:56
  • i can't change this scenario, need to solve it with this configuration. Thanks, David =) – sergius Dec 8 '15 at 20:23

DNAT may suffice:

# iptables -t nat -A PREROUTING -i eth0 -p tcp -d --dport 8080 -j DNAT --to-destination

The UFW before.rules file from some altagoobingleduckgoing looks like it uses the iptables-save format, so thus may contain something along the lines of:

-A PREROUTING -i eth0 -p tcp -d --dport 8080 -j DNAT --to-destination

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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