Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

For some reason my CentOS VPS refuses all connections except for HTTP, SSH and Telnet. Whenever I try to connect to a port such as 25 (SMTP) or even a random port such as 225 I get a connection refused error :S netstat -ap shows that the server is listening and iptables is turned off.

However I can interface with the same ports on the server through telnet...

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination    

# netstat -an | fgrep LISTEN
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      
tcp        0      0 0.0.0.0:225                 0.0.0.0:*                   LISTEN      
tcp        0      0 :::22                       :::*                        LISTEN      
tcp        0      0 :::80                       :::*                        LISTEN      
unix  2      [ ACC ]     STREAM     LISTENING     169786017 /tmp/.font-unix/fs7100
unix  2      [ ACC ]     STREAM     LISTENING     169786045 /var/run/saslauthd/mux

This is the error message i'm getting from my php script. My PHP script works fine with every other SMTP server I've come across Warning: fsockopen() [function.fsockopen]: unable to connect to :25 (Connection refused)

share|improve this question
    
So is it possible that your ISP only allows a handful ports?! –  mailq Oct 9 '11 at 20:39
    
Nope, it lets me connect to other servers, just not my VPS. –  Andrew Dunn Oct 9 '11 at 20:40
    
Or did you mean my VPS ISP? –  Andrew Dunn Oct 9 '11 at 20:40
    
Are you certain iptables isn't running ? –  Iain Oct 9 '11 at 20:42
    
yes, that is what @mailq mean. Did your ISP (as in your VPS provider) put a firewall in front of your VPS? Out of curiosity, what ports should be accessible? –  Rilindo Oct 9 '11 at 20:44

2 Answers 2

up vote 2 down vote accepted

It looks like there is something upstream of your VPS that is blocking access except for the ports noted. You should contact your VPS provider and ask them about it.

share|improve this answer
    
You were right, they blocked pretty much everything, I solved it by running my SMTP server on port 80 :P –  Andrew Dunn Oct 9 '11 at 22:44

Okay, to make things clear - if you are running CentOS, chances are that you are at release 5 with sendmail as the default. In that case, you will not be to connect externally, because sendmail will only listen to localhost by default. To make it listen on the main IP, you will need to disable the line in /etc/sendmail.mc from this:

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

to this:

dnl DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl

Then rebuild sendmail.cf with the following:

/etc/mail/make
/etc/init.d/sendmail restart

(if it is postfix, it may be a different story. IIRC, postfix will only listen by default on localhost as well, so you will need to configure it as well to listen on the main IP).

HOWEVER, since you are just trying to test external connectivity, you may just need to install nc and then run it to listen to a specific. Here is my example:

[root@kvm0006 mail]# nc -l 50

Here I am listening on port 50 (hence, the -l). Now when I connect from outside the server on that port, I will get this:

yvaine:Downloads rilindo$ telnet 192.168.15.36 50
Trying 192.168.15.36...
Connected to kvm0006.monzell.com.
Escape character is '^]'.
Hello

Which will return the following on the server side:

[root@kvm0006 mail]# nc -l 50
Hello

To install nc:

yum -y install nc
share|improve this answer
    
Unfortunately I have already done that to no avail :( –  Andrew Dunn Oct 9 '11 at 21:23
    
And for some reason connecting through telnet works, but connecting directly doesn't. –  Andrew Dunn Oct 9 '11 at 21:23
    
And that includes telnet from a remote server. –  Andrew Dunn Oct 9 '11 at 21:27
    
doesn't 0.0.0.0:25 mean listening on port 25 for all available interfaces ? –  Iain Oct 9 '11 at 21:31
    
Can we get the output of your telnet test? And when you do a telnet test, can you do a tcpdump on the server interface, so that we can see that there is actually two way traffic? –  Rilindo Oct 9 '11 at 21:31

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.