W
W
webe2021-08-19 15:55:42
linux
webe, 2021-08-19 15:55:42

How to open a port correctly?

I use the site https://portscaner.ru/ to check the opening of ports.
I enter 22 - everything is OK, there is access.
I enter 21 - access is closed. sudo

ufw status
611e54cc6b858292301415.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor Taran, 2021-08-19
@webe

If you have iptables

iptables -I INPUT -p tcp --dport 22 -j ACCEPT
iptables -I INPUT -p tcp --dport 21 -j ACCEPT
service iptables save

If you have a firewall
firewall-cmd --zone=public --add-port=22/tcp   --permanent
firewall-cmd --zone=public --add-port=21/tcp   --permanent

ufw
sudo ufw allow 22/tcp
sudo ufw allow 21/tcp

Also outline your system for accessing the Internet, most likely you are behind NAT and your router sets it.
Therefore, port forwarding needs to be done on the router.
That is, the port is now closed on the router itself, and if you open it, it will be available on the router itself,
respectively, you need to find a place where the following rule is added
22-> 22 tcp 192.168.1.2
something like this
That is, which external port, which it will be a port within the network and, accordingly, to which internal IP to give it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question