1

I have two interfaces eth0 (192.168.1.2) and eth1 (192.168.3.2).

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
2

DNAT may suffice:

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

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:

*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -i eth0 -p tcp -d 192.168.1.2 --dport 8080 -j DNAT --to-destination 192.168.3.2:80
COMMIT

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.