P
P
pavelpasha2018-09-12 16:12:06
linux
pavelpasha, 2018-09-12 16:12:06

How to forward packets from a specific port to another interface?

The situation is this: there is a Raspberry behind a NAT (GSM modem), a data logger is connected to it via LAN. Through the remot3.it service, I remotely access port "1234" on raspberry. How can I reach the datalogger?
Those. I need to redirect all packets coming to port 1234 to 192.168.0.255:61234.
What I tried:
The address of the distribution in the LAN is the gateway for the data logger.
Tried to set up port forwarding

iptables -t nat -A PREROUTING -p tcp --dport 1234-j DNAT --to-destination 192.168.0.255:61234

28YQp.png
(/22 subnet between the data logger and the raspeber, because the address is .255)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-09-12
@q2digger

At first glance, you did everything right. It is worth checking what you can do with the forwarding table:
and make sure that traffic from external resources to the internal address is allowed.
Add if necessary.
And it’s also worth checking that forwarding is enabled in the kernel, check like this:, if necessary,
cat /proc/sys/net/ipv4/ip_forwardenable
echo 1 > /proc/sys/net/ipv4/ip_forward

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question