Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

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
$ 
share|improve this answer
    
Yeah I was persuaded that my tomcat server was listening to this port but it wasn't! The error came from here! Thanks. –  darkheir Sep 25 '13 at 15:17
add comment

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|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.