There are three devices.
One I want to connect with.
The second I want to connect to.
And third, between them, through which I want to connect and on which I do port forwarding.
Port forwarding as follows:

iptables -t nat -A PREROUTING -p tcp --dport 5034 -j DNAT --to-destination 192.168.0.34:22 

Some ports work and I can easily connect via ssh via this route.
But through some ports it does not connect at all, although it was possible before.
For myself, I dug up that in the log /var/log/ufw.log at the moment when I want to connect through the problem port such lines appear:

 Jul 11 13:04:58 server kernel: [ 1637.309108] [UFW BLOCK] IN=eth0 OUT= MAC=01:12:6c:02:0a:0e:8e:5d:4e:a7:f0:00:05:00 SRC=11.22.33.44 DST=55.66.77.88 LEN=52 TOS=0x00 PREC=0x00 TTL=119 ID=27333 DF PROTO=TCP SPT=5066 DPT=5034 WINDOW=65535 RES=0x00 SYN URGP=0 

But if ufw is stopped, it is still not possible to connect through the broken ports, and nothing is written in the log.
There are also ports through which the connection also fails, but does not write anything in the ufw log, even if it is enabled.
These ports should not be busy, netstat showed nothing, and I tried 40000+

What can be wrong? How can you check what goes wrong?

    1 answer 1

    If not firewall, then apparmor or selinux.

    To begin, view all the firewall rules:

     sudo iptables-save 

    If there are no locks, then see the log here

     tail -f /var/log/auth.log 

    or

     journalctl -f -l SYSLOG_FACILITY=10