LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-18-2016, 03:42 PM   #1
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Rep: Reputation: Disabled
Learning Linux: telnet and SMTP


I have three questions about telnet and smtp.

First I check to see if smtp service is available on CentOS7:
Code:
[student@localhost ~]$ systemctl status | grep -i smtp
           │     └─5450 grep --color=auto -i smtp
[student@localhost ~]$
Q1: So smtp is not running, correct?
Services should show up on systemctl. No?

But on netstat, it shows smtp is running:

Code:
student@localhost ~]$ netstat -taupe | grep smtp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      root       24224      -                   
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      root       24225      -
Looks like localhost has smtp running on all ports, 0.0.0.0:* .
Q2: So why is smtp not showing up on command output like so:
Code:
systemctl status | grep -i smtp
Since smtp is on localhost,
I should be able to telnet into localhost like so:

Code:
[student@localhost ~]$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix
#Not getting a telnet prompt, "telnet>".
BUT netstat shows I am connected like so:
(Shown on last line for user, student. )
Code:
[student@localhost ~]$ netstat -taupe | grep smtp
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      root       24224      -                   
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      root       24225      -                   
tcp6       0      0 localhost:smtp          localhost:56974         ESTABLISHED postfix    59454      -                   
tcp6       0      0 localhost:56974         localhost:smtp          ESTABLISHED student    59295      5677/telnet
Q3: So why am I not getting a telnet prompt?


What did I missed?
Thanks.

Last edited by fanoflq; 11-18-2016 at 03:45 PM.
 
Old 11-18-2016, 03:47 PM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
Telnet onto a different port will not provide "a telnet prompt". It performs a TCP test on the specific application running on that port
 
1 members found this post helpful.
Old 11-18-2016, 03:53 PM   #3
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
If you telnet to port 80 on a web server, you can issue a "get" command to confirm you receive a web page.

If you telnet to port 25 on a mail server, you can issue SMTP commands like "ehlo" to confirm the SMTP service is working

Your output states you are using postfix so if you want to check the services it should be for postfix
 
1 members found this post helpful.
Old 11-18-2016, 03:57 PM   #4
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Disillusionist View Post
Telnet onto a different port will not provide "a telnet prompt". It performs a TCP test on the specific application running on that port

What port should I telnet?
 
Old 11-18-2016, 04:00 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,215

Rep: Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993
SMTP i.e Simple Mail Transfer Protocol is not a service. It is how some mail clients/servers talk to each other. The service that is running is postfix which by default runs on port 25. Since SMTP is ASCII you can use telnet to communicate with the postfix server but it isn't like a regular terminal session.

You can find many websites that post how to test SMTP via telnet.
http://www.cisco.com/c/en/us/support...te-esa-00.html
https://technet.microsoft.com/en-us/...exchg.65).aspx
 
1 members found this post helpful.
Old 11-18-2016, 04:00 PM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
It's not that you shouldn't telnet to port 25 to test smtp access, but it will not act like a normal telnet session

It will let you issue smtp related commands and even let you send an email
 
1 members found this post helpful.
Old 11-18-2016, 04:01 PM   #7
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Disillusionist View Post
If you telnet to port 80 on a web server, you can issue a "get" command to confirm you receive a web page.

If you telnet to port 25 on a mail server, you can issue SMTP commands like "ehlo" to confirm the SMTP service is working

Your output states you are using postfix so if you want to check the services it should be for postfix

Code:
[student@localhost ~]$ telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 localhost.localdomain ESMTP Postfix
ehlo
501 Syntax: EHLO hostname
Thanks.
So it is working.
But why does it not show up as output of command: systemctl status ?

How do I enable a telnet prompt?
 
Old 11-18-2016, 04:12 PM   #8
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
Have you had a chance to read through the links provided by Michaelk?

From testing your service, what happens when you run:

systemctl status | grep -i postfix
 
1 members found this post helpful.
Old 11-18-2016, 04:20 PM   #9
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Disillusionist View Post
Have you had a chance to read through the links provided by Michaelk?

From testing your service, what happens when you run:

systemctl status | grep -i postfix
Yes...
 
Old 11-18-2016, 04:25 PM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,215

Rep: Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993
The telnet protocol works like a terminal program for human interaction to a remote computer but SMTP is not. Since it does not work the same there isn't a prompt.
 
1 members found this post helpful.
Old 11-18-2016, 05:15 PM   #11
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
One more problem.

The above OP was done using a virtual machine.
And I telnet from within the VM to its own localhost.

Its IP addresses are:

Quote:
[student@localhost ~]$ ip a | grep "inet "
inet 127.0.0.1/8 scope host lo
inet 192.168.0.17/24 brd 192.168.0.255 scope global dynamic eno16777736
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
Not I want to telnet into the VM's smtp from its host, my laptop.
Pinging from my laptop works for both IPs:

Quote:
$ ping 192.168.0.17
PING 192.168.0.17 (192.168.0.17) 56(84) bytes of data.
64 bytes from 192.168.0.17: icmp_seq=1 ttl=64 time=0.960 ms
64 bytes from 192.168.0.17: icmp_seq=2 ttl=64 time=0.784 ms
64 bytes from 192.168.0.17: icmp_seq=3 ttl=64 time=0.836 ms
^C
--- 192.168.0.17 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.784/0.860/0.960/0.073 ms

$ ping 192.168.122.1
PING 192.168.122.1 (192.168.122.1) 56(84) bytes of data.
64 bytes from 192.168.122.1: icmp_seq=1 ttl=64 time=0.107 ms
64 bytes from 192.168.122.1: icmp_seq=2 ttl=64 time=0.093 ms
64 bytes from 192.168.122.1: icmp_seq=3 ttl=64 time=0.092 ms
^C
--- 192.168.122.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.092/0.097/0.107/0.010 ms
Then I telnet:
Quote:
$ telnet 192.168.0.17 25
Trying 192.168.0.17...
telnet: Unable to connect to remote host: Connection refused
$ telnet 192.168.122.1 25

Trying 192.168.122.1...
telnet: Unable to connect to remote host: Connection refused
$
I thought it was a firewall problem.
So I disabled the firewall:

Quote:
[student@localhost ~]$ systemctl status | grep firewall
│ ├─7667 man firewall-cmd
│ └─7947 grep --color=auto firewall
├─firewalld.service
│ └─790 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

[student@localhost ~]$ systemctl stop firewalld.service

[student@localhost ~]$ systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Fri 2016-11-18 14:44:40 MST; 11s ago
Process: 790 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 790 (code=exited, status=0/SUCCESS)

Nov 18 12:38:14 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Nov 18 12:38:16 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Nov 18 14:44:38 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
Nov 18 14:44:40 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
[student@localhost ~]$
And I still is not able to telnet into smtp on virtual machine:
Quote:
$ telnet 192.168.122.1 25
Trying 192.168.122.1...
telnet: Unable to connect to remote host: Connection refused

$ telnet 192.168.0.17 25
Trying 192.168.0.17...
telnet: Unable to connect to remote host: Connection refused
What did I missed?
Thanks!

Last edited by fanoflq; 11-18-2016 at 05:21 PM.
 
Old 11-18-2016, 05:37 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,215

Rep: Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993
virbr0 is acting as a NAT router and I would guess that the host services are not listening on the virtual interface. If you want to access the host services from the guest you might need to configure it as a bridge.
 
Old 11-18-2016, 05:40 PM   #13
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
Your previous output from netstat shows smtp listening on localhost therefore it is only available from within the host

You will need to look at changing your postfix configuration to listen on the IP of the server
 
Old 11-18-2016, 06:26 PM   #14
fanoflq
Member
 
Registered: Nov 2015
Posts: 397

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
virbr0 is acting as a NAT router and I would guess that the host services are not listening on the virtual interface. If you want to access the host services from the guest you might need to configure it as a bridge.
I have rebooted the laptop.
thus the VM's IP has changed.
Here is the VM's network setup:

Code:
[student@localhost ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:e1:93:0b brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.145/24 brd 10.0.0.255 scope global dynamic eno16777736
       valid_lft 604657sec preferred_lft 604657sec
    inet6 fe80::20c:29ff:fee1:930b/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:ae:4d:5c brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
    link/ether 52:54:00:ae:4d:5c brd ff:ff:ff:ff:ff:ff
Notice virtual bridge, virbr0, is DOWN.
And here is what I tried with no success, meaning virtual bridge's state is still DOWN:

Code:
[student@localhost ~]$ sudo ip link set virbr0 up
[student@localhost ~]$ sudo ip link show virbr0
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT 
    link/ether 52:54:00:ae:4d:5c brd ff:ff:ff:ff:ff:ff

I look into nmtui, and I am not sure what to do next to enable virbr0.
virbr0 is already in nmtui.
There is no provision to turn it on in nmtui.

Here is the screen shot from VMware's setup:
(There is no add image icon button in menu area for me to insert image here!
But I was able to attach it to this pos
t.)

Looks like the setup in VMware is correct, no?

What to do?
Thanks.
Attached Thumbnails
Click image for larger version

Name:	Selection_001.png
Views:	11
Size:	61.6 KB
ID:	23569  

Last edited by fanoflq; 11-18-2016 at 06:30 PM.
 
Old 11-18-2016, 06:31 PM   #15
michaelk
Moderator
 
Registered: Aug 2002
Posts: 19,215

Rep: Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993Reputation: 2993
As Disillusionist posted postfix by default only listens to localhost. Edit inet_interfaces in the file /etc/postfix/main.cf

# Listen to all interfaces rather than strict to localhost
inet_interfaces = all

Just curious as to what you are trying to accomplish.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Mail using telnet SMTP tusharsharma43 Linux - Newbie 2 02-24-2015 08:26 AM
telnet to smtp SERVER mr.cracker Linux - Server 15 06-21-2013 06:25 AM
Cant Telnet SMTP pbaker Linux - Server 9 05-28-2010 05:11 PM
smtp problem..telnet to 25 rnj Linux - Newbie 9 12-12-2005 11:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration