Testing network services using telnet

Share

Information bellow from TN1437778

Many internet protocols are ascii based and can be accessed through a simple telnet connection. You may want to use telnet to troubleshoot many of these products so that you can remove a lot of the complexity.

HTTP connections
1.        Connect to the target server using telnet, specify the port for the web service.
telnet serverName port
2.        Once connected to the server type the following replacing the serverName with the website’s internet address:
GET / HTTP/1.1
host: serverName
3.        Press the Enter key twice.
4.        The output of the command will be some headers and the html of the page.
HTTP/1.1 200 OK
Date: Thu, 18 Nov 2010 18:49:01 GMT
Server: Apache
X-Powered-By: PHP/5.2.5
Transfer-Encoding: chunked
Content-Type: text/html

21c

Web Server Admin
…..
SSL connection
1.        Telnet into the server as an administrative user.
2.        Once connected, type the following, replacing the serverName with the website’s internet address.
openssl s_client -connect serverName:port -crlf

3.        The security handshake will scroll across the screen.
4.        Type the following, replacing the serverName with the website’s internet address.
GET / HTTP/1.1
host: serverName

5.        Press the Enter key twice.
6.        The output of the command will be some headers and the html of the page.
HTTP/1.1 200 OK
Date: Thu, 18 Nov 2010 18:49:01 GMT
Server: Apache
X-Powered-By: PHP/5.2.5
Transfer-Encoding: chunked
Content-Type: text/html

21c

Web Server Admin
…..

SMTP
1.        Using telnet connect to the server on port 25.
telnet serverName 25
2.        Type the following lines replacing the email addresses as appropriate. The lines starting with a number are server responses and should not be entered. For a full list of SMTP commands refer to RFC 5321.
helo me

250 lfs122.example.in
mail from:
senderEmailAddress
250 Ok
rcpt to:
recipientEmailAddress
250 Ok
data

354 End data with .
Subject: Test from telnet
.

250 Ok: queued as 12E7F1AC09D
3.        When done use the ‘quit’ command to close the server connection.
POP3
1.        Using telnet connect to the server on port 110
telnet serverName 110
2.        Enter the following, replacing userName and password with the correct values. The lines starting with +OK and numbers are server responses. The response text may be different. For a full list of POP3 commands refer to RFC 1939.
user userName
+OK Name is a valid mailbox
pass password
+OK Mailbox locked and ready
stat
+OK 1 758
list
+OK scan listing follows
1 758
.
retr 1
+OK Message follows
Return-Path:
….
3.        When finished use the “quit” command to close the server connection.
IMAP Connections
1.        Using telnet connect to the server on port 143
telnet serverName 143
2.        Enter the following, replacing userName and password with the correct values. Each command line starts with a period (.) followed by a space and then the command. The lines starting with asterisks * and numbers are server responses. For a full list of IMAP commands refer to RFC 3501.
. login userName password
. OK User logged in
. list “” “*”    
* LIST (HasChildren) “/” “INBOX”
* LIST (HasNoChildren) “/” “INBOX/Spam”
. OK Completed (0.000 secs 3 calls)
. status inbox (messages)
* STATUS inbox (MESSAGES 1)
. OK Completed
3.        When finished use the “. logout” command to disconnect from the server.