B
B
BarakudaX7772018-12-30 09:14:57
linux
BarakudaX777, 2018-12-30 09:14:57

How to forward the port of the local machine to the outside in LINUX?

Good afternoon! Please prompt: There is a computer in the local network 192.168.30.202. This machine's gateway is 192.168.30.1, on Ubuntu 18.04 with squid installed.
It is necessary that port 62066, open on the local machine, be accessible through an external static IP address (83.146.113.23) on the same port 62066.
That is, it is necessary that packets arriving on the external interface be sent to the local machine and back from it.
What has been done:
The port on the local machine is open and listening. Through telnet from any local machine on 30.202 on this port comes, nothing is blocked.
On the iptables gateway, I wrote the rules:

с внешки на внутренний - iptables -t nat -A PREROUTING -p tcp -m tcp -d 83.146.113.23 --dport 62066 -j DNAT --to-destination 192.168.30.202:62066
с нутреннего на внешний - iptables -t nat -A POSTROUTING -p tcp -m tcp -d 192.168.30.202 --dport 62066 -j SNAT --to-source 83.146.113.23:62066

The port is not opening. telnet does not connect, through the portscan website it says that this port is closed ... I don’t understand what else needs to be done?
iptables -L -t nat | grep 62066
DNAT       tcp  --  anywhere             23.113.146.83.in-addr.suttk.ru  tcp dpt:62066 to:192.168.30.202:62066
SNAT       tcp  --  anywhere             192.168.30.202       tcp dpt:62066 to:83.146.113.23:62066

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BarakudaX777, 2018-12-30
@BarakudaX777

Missing iptables -I FORWARD 1 -i enp3s1 -o enp4s0 -d 192.168.30.202 -p tcp -m tcp --dport 62066 -j ACCEPT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question