Posts: 1
Joined: Fri Oct 05, 2018 9:52 pm

Port forwarding to a different interface ip:port

Fri Oct 05, 2018 10:04 pm

Hi Guys,
I'm having some issues trying to forward traffic from a specific port on eth1 to an ip address and port on eth0.

For example is my usb 4g stick and where my ddns is going to, eth1 is sitting on, and i need to forward traffic from outside on the ddns port 15201 through the pi on eth0( to I've got about 4 different ports to do.
I've allowed ipv4 forwarding and now i've got to iptables and i'm baffled, i've been trying along the lines of;

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 15201 -o eth0 --destination but it won't stick..! and is saying host/network not found.

Is anyone able to help - as i'm starting to go bald!
Also, is there an easy way to create eth1 as the default nic and gateway?

Kind Regards,

Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Port forwarding to a different interface ip:port

Sat Oct 06, 2018 2:20 pm

This works with some devices.

Code: Select all

sudo iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination
Edit /etc/sysctl.conf and uncomment

Code: Select all


Return to “Networking and servers”