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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
11-18-2016, 02:42 PM
|
#1
|
Member
Registered: Nov 2015
Posts: 397
Rep: 
|
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 02:45 PM.
|
|
|
11-18-2016, 02:47 PM
|
#2
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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.
|
11-18-2016, 02:53 PM
|
#3
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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.
|
11-18-2016, 02:57 PM
|
#4
|
Member
Registered: Nov 2015
Posts: 397
Original Poster
Rep: 
|
Quote:
Originally Posted by Disillusionist
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?
|
|
|
11-18-2016, 03:00 PM
|
#5
|
Moderator
Registered: Aug 2002
Posts: 26,913
|
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.
|
11-18-2016, 03:00 PM
|
#6
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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.
|
11-18-2016, 03:01 PM
|
#7
|
Member
Registered: Nov 2015
Posts: 397
Original Poster
Rep: 
|
Quote:
Originally Posted by Disillusionist
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?
|
|
|
11-18-2016, 03:12 PM
|
#8
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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.
|
11-18-2016, 03:20 PM
|
#9
|
Member
Registered: Nov 2015
Posts: 397
Original Poster
Rep: 
|
Quote:
Originally Posted by Disillusionist
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...
|
|
|
11-18-2016, 03:25 PM
|
#10
|
Moderator
Registered: Aug 2002
Posts: 26,913
|
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.
|
11-18-2016, 04:15 PM
|
#11
|
Member
Registered: Nov 2015
Posts: 397
Original Poster
Rep: 
|
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 04:21 PM.
|
|
|
11-18-2016, 04:37 PM
|
#12
|
Moderator
Registered: Aug 2002
Posts: 26,913
|
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.
|
|
|
11-18-2016, 04:40 PM
|
#13
|
Senior Member
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039
Rep:
|
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
|
|
|
11-18-2016, 05:26 PM
|
#14
|
Member
Registered: Nov 2015
Posts: 397
Original Poster
Rep: 
|
Quote:
Originally Posted by michaelk
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 post.)
Looks like the setup in VMware is correct, no?
What to do?
Thanks.
Last edited by fanoflq; 11-18-2016 at 05:30 PM.
|
|
|
11-18-2016, 05:31 PM
|
#15
|
Moderator
Registered: Aug 2002
Posts: 26,913
|
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.
|
All times are GMT -5. The time now is 08:01 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|