Open a port in my CentOS

7,203

Solution 1

Is there a service running on that port after you've opened it? The command netstat -tulpn | less will only show you the ports of daemons that are actually listening on TCP ports.

Example

Nothing's initially running:

$ sudo netstat -tulpn | grep :80
$

Start up Apache:

$ sudo /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
$

Check again:

$ sudo netstat -tulpn | grep :80
tcp        0      0 :::80                       :::*                        LISTEN      31260/httpd    

Now we see it. Stop the service:

$ sudo /etc/init.d/httpd stop
Stopping httpd:                                            [  OK  ]
$

Now it's gone again.

$ sudo netstat -tulpn | grep :80
$ 

Solution 2

The iptables rule is just saying that any incoming TCP segment with destination port 143 will be accepted and not e.g. DROPped when default chain policy is set to DROP or REJECTed when the segment is not matched by any rule and the last rule in the chain is REJECT.

If you want to see this port as opened and in listening state there has to be some application running and listening on that port. Apparently, there is not such app running so try to configure it first and then start it. The TCP port 143 is in general allocated for IMAP services (aka Dovecot, Courier-imap and so on).

Share:
7,203

Related videos on Youtube

darkheir
Author by

darkheir

Updated on September 18, 2022

Comments

  • darkheir
    darkheir over 1 year

    I'm trying top open a port on my CentOS machine:

    I edit the /etc/sysconfig/iptables file and add my rule:

    -A INPUT -p TCP -m state --state NEW -m tcp --dport 143 -j ACCEPT
    

    Then I restart the iptable service

    # service iptables restart
    

    But when I'm checking the open ports the one I declared doesn't appear

    netstat -tulpn | less
    
  • darkheir
    darkheir over 10 years
    Yeah I was persuaded that my tomcat server was listening to this port but it wasn't! The error came from here! Thanks.