How do I open a port in Ubuntu?
I'm new to ubuntu, so I can't figure out why the port doesn't open and how to do it anyway. Tell me, please!
I tried to open the port in iptables, but as I understood, iptables are used to control the ufw firewall, and when I enter the sudo ufw status
command, I get a response:
sudo: ufw: command not found
How do I open the port in this case? Googling only advised me to use iptables.
Just in case, I will give the output of the command netstat -an | grep LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:953 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:587 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:80 0.0.0.0:* LISTENtcp 0 0 5.231.61.235:53 0.0.0.0:* LISTENtcp 0 0 127.0.0.2:53 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:53 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:22 0.0.0.0:* LISTENtcp 0 0 127.0.0.1:631 0.0.0.0:* LISTENtcp6 0 0 ::1:953 :::* LISTENtcp6 0 0 :::53 :::* LISTENtcp6 0 0 :::22 :::* LISTENtcp6 0 0 ::1:631 :::* LISTENunix 2 [ ACC ] STREAM LISTENING 3215411995 /var/run/cups/cups.sockunix 2 [ ACC ] STREAM LISTENING 3215409707 /var/run/avahi-daemon/socketunix 2 [ ACC ] STREAM LISTENING 3215403381 @/com/ubuntu/upstartunix 2 [ ACC ] STREAM LISTENING 3215406175 /var/run/dbus/system_bus_socketunix 2 [ ACC ] STREAM LISTENING 3215553140 /var/run/sendmail/mta/smcontrolunix 2 [ ACC ] STREAM LISTENING 3215421071 /var/run/acpid.socketunix 2 [ ACC ] SEQPACKET LISTENING 3215405745 /run/udev/controlunix 2 [ ACC ] STREAM LISTENING 3215427067 /var/run/saslauthd/mux
That is, like the 53rd port is open... How else can I open the ports?
3 answers
Your listing is not open ports, but the output of who listens to which ports.
If you want to open port 53 over tcp, for example, using the iptables utility:
iptables -I INPUT -p tcp -m tcp --dport 53 -j ACCEPT
If we are talking about ubuntu, and after installing it, no ADDITIONAL actions were taken on the firewall, then ALL ports are OPEN
Install the ufw utility:
apt-get install ufw