LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-25-2011, 08:22 AM   #1
showe123
Member
 
Registered: Aug 2010
Posts: 58

Rep: Reputation: 0
telnet to port 25 not working from outside


Hi,

I'm trying to test smtp connectivity to my postfix configuration and I can telnet to port 25 from the computer itself but cannot from the outside. I get a connection refused error message. What am I doing wrong? I believe my dns is setup correctly as it seems the telnet can hit the box so I'm fairly sure its not that.

Thanks.
 
Old 03-25-2011, 08:45 AM   #2
linuxgurusa
Member
 
Registered: Mar 2008
Location: Namibia, Swakopmund
Distribution: Redhat, Fedora, Centos, ClearOS, Mandrake
Posts: 151

Rep: Reputation: 29
Quote:
Originally Posted by showe123 View Post
Hi,

I'm trying to test smtp connectivity to my postfix configuration and I can telnet to port 25 from the computer itself but cannot from the outside. I get a connection refused error message. What am I doing wrong? I believe my dns is setup correctly as it seems the telnet can hit the box so I'm fairly sure its not that.

Thanks.
DO the following command, and see if your port 25 is running on 0.0.0.0 or 127.0.0.1, which is wrong (127.0.0.1)

netstat -an | grep LIST

It must not be be

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

but

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
 
1 members found this post helpful.
Old 03-25-2011, 08:46 AM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Is iptables enabled on the box? Is there a firewall between the two?
 
1 members found this post helpful.
Old 03-25-2011, 08:47 AM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Is postfix listening on your public IP? do: lsof -ni tcp:25. If you only see postfix listening on localhost, you need to configure it to listen on all interfaces instead.

Or you may have a firewall on that is refusing connections, or a router in the way that is not forwarding the port.
 
1 members found this post helpful.
Old 03-25-2011, 09:00 AM   #5
showe123
Member
 
Registered: Aug 2010
Posts: 58

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by linuxgurusa View Post
DO the following command, and see if your port 25 is running on 0.0.0.0 or 127.0.0.1, which is wrong (127.0.0.1)

netstat -an | grep LIST

It must not be be

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN

but

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

It's showing 127.0.0.1:25 0.0.0.0* LISTEN

What does that mean?
 
Old 03-25-2011, 09:01 AM   #6
showe123
Member
 
Registered: Aug 2010
Posts: 58

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by AlucardZero View Post
Is postfix listening on your public IP? do: lsof -ni tcp:25. If you only see postfix listening on localhost, you need to configure it to listen on all interfaces instead.

Or you may have a firewall on that is refusing connections, or a router in the way that is not forwarding the port.
I don't have any firewall on and it does seem to be listening on localhost only. How do I change it to listen on all interfaces?
 
Old 03-25-2011, 09:11 AM   #7
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Why are you trying to telnet to your smtp port? They're completely different services. Telnet is usually listening on port 21.
 
Old 03-25-2011, 09:11 AM   #8
showe123
Member
 
Registered: Aug 2010
Posts: 58

Original Poster
Rep: Reputation: 0
Maybe i should add that this is related to the problem I have of only being able to send email and not receive. Perhaps it does have something to do with DNS too?
 
Old 03-25-2011, 09:17 AM   #9
linuxgurusa
Member
 
Registered: Mar 2008
Location: Namibia, Swakopmund
Distribution: Redhat, Fedora, Centos, ClearOS, Mandrake
Posts: 151

Rep: Reputation: 29
Quote:
Originally Posted by showe123 View Post
It's showing 127.0.0.1:25 0.0.0.0* LISTEN

What does that mean?
That is your problem right there buddy

If you do

netstat -an | grep LIST

It must show

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

By default your MTA is configured to ONLY listen on your localhost (127.0.0.1) to prevent spammers from picking up a newbie mail server installation

You must change your postfix mc file to listen on 0.0.0.0 and not on 127.0.0.1

DO you know how to do that ?
 
Old 03-25-2011, 09:19 AM   #10
linuxgurusa
Member
 
Registered: Mar 2008
Location: Namibia, Swakopmund
Distribution: Redhat, Fedora, Centos, ClearOS, Mandrake
Posts: 151

Rep: Reputation: 29
Quote:
Originally Posted by SL00b View Post
Why are you trying to telnet to your smtp port? They're completely different services. Telnet is usually listening on port 21.
You are missing the point of this excersise bud

If you do

telnet 127.0.0.1

You will make a connection on port 23 yes

If you do the following

telnet 127.0.0.1 25

Then you make a port 25 connection and not a port 23 connection

You can also telnet to port 22, 80, 110, 143 etc to test and see if your ports are listening etc.

Last edited by linuxgurusa; 03-28-2011 at 01:11 AM.
 
Old 03-25-2011, 09:21 AM   #11
showe123
Member
 
Registered: Aug 2010
Posts: 58

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by linuxgurusa View Post
That is your problem right there buddy

If you do

netstat -an | grep LIST

It must show

tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN

By default your MTA is configured to ONLY listen on your localhost (127.0.0.1) to prevent spammers from picking up a newbie mail server installation

You must change your postfix mc file to listen on 0.0.0.0 and not on 127.0.0.1

DO you know how to do that ?


No, I don't. Im the newbie mail server installation that spammers love I guess.
 
Old 03-25-2011, 09:23 AM   #12
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by SL00b View Post
Why are you trying to telnet to your smtp port? They're completely different services. Telnet is usually listening on port 21.
If you have an MTA listening on port 25 then when you telnet to that port you should see a response. That will tell you if the MTA is listening. This is a widely used test procedure.
 
Old 03-25-2011, 09:25 AM   #13
linuxgurusa
Member
 
Registered: Mar 2008
Location: Namibia, Swakopmund
Distribution: Redhat, Fedora, Centos, ClearOS, Mandrake
Posts: 151

Rep: Reputation: 29
Quote:
Originally Posted by showe123 View Post
No, I don't. Im the newbie mail server installation that spammers love I guess.
LOL, no worries.

I use Sendmail all the time, but I will try and help, since I have done Postfix installs as well, much stronger than Sendmail

OK, so ..

Edit /etc/postfix/master.cf file

look for the line with the 127.0.0.1 in it

replace the 127.0.0.1 with 0.0.0.0

save and quit file, restart postfix, let me know
 
1 members found this post helpful.
Old 03-25-2011, 09:37 AM   #14
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by linuxgurusa View Post
You are missing the point of this excersise bud

If you do

telnet 127.0.0.1

You will make a connection on port 21 yes

If you do the following

telnet 127.0.0.1 25

Then you make a port 25 connection and not a port 21 connection

You can also telnet to port 22, 80, 110, 143 etc to test and see if your ports are listening etc.
It's axiomatic that someone will always quote your post if you make a simple mistake, so first let me clear up that telnet is port 23, not 21. Port 21 is default for FTP. I always seem to reverse those two, because it seems to me that ssh (port 22) should have come AFTER the unsecured version.

With that said, I was unaware of this trick, which is why I asked the question. It's still more useful to test the connection with the right kind of request, though. All the telnet trick will tell you is that something is listening there, whereas sending a simple smtp message will test that and more.
 
Old 03-25-2011, 09:54 AM   #15
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
Originally Posted by SL00b View Post
It's axiomatic that someone will always quote your post if you make a simple mistake, so first let me clear up that telnet is port 23, not 21. Port 21 is default for FTP. I always seem to reverse those two, because it seems to me that ssh (port 22) should have come AFTER the unsecured version.

With that said, I was unaware of this trick, which is why I asked the question. It's still more useful to test the connection with the right kind of request, though. All the telnet trick will tell you is that something is listening there, whereas sending a simple smtp message will test that and more.
Thats an aphorism for sure.

Using telnet to connect to the mail server, will certainly give you more than just an ack that something is listening. It should give an insight into what is going on. Of course, you have to do this once connected:
Code:
HELO
MAIL FROM:someuser@somehwere.com
RCPT TO:someone@gmail.com
DATA
blah blah blah
.
exit
You should see plenty of output while doing this. After that, the logs are a good place to go.

Last edited by szboardstretcher; 03-25-2011 at 09:56 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PLESK [Solution] Change port to 23 (telnet) instead of default port 8443 x5452 Linux - Software 6 05-10-2009 05:58 AM
telnet to port 80 nima0102 Linux - Networking 2 11-16-2008 03:26 PM
telnet to port 22 icechong Linux - Newbie 9 03-08-2007 01:25 AM
telnet port 25 frankcchan Linux - Software 2 12-30-2006 11:38 PM
telnet to port 80 davee Linux - Networking 5 08-06-2003 03:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration