telnet — Raw TCP connection and port check
Linux / Network and Firewall / telnet.html
A classic client that opens a raw TCP connection so you can see what a service answers.
Basic Information
| Command Name | telnet |
|---|---|
| One-line Introduction | A classic client that opens a raw TCP connection so you can see what a service answers. |
| Provided by | telnet client (packaged by distributions) |
| Official Documentation | https://man7.org/linux/man-pages/man1/telnet.1.html |
| Supported Operating Systems | Linux, macOS, BSD |
| Installation Status | Package required (apt install telnet) |
| Category | Linux networking (tags: Address, port and firewall management (tags: TCP, port, connection, diagnose)) |
What is this command?
telnet opens a TCP connection and sends whatever you type without encryption.
It is used for port checks and legacy text protocols, not for secure remote login.
What problems does it solve?
- Check whether a service listens on a port.
- Verify that a firewall rule allows the path.
- Exercise plain-text protocols such as SMTP or HTTP by hand.
- Read the banner and response exactly as sent.
Key features
Port connection
Give a host and port to attempt a connection.
- When to use: When you need a quick open/closed check.
- What you get: A banner or prompt appears when it connects.
- Limitations: Nothing is encrypted, so never send secrets.
Protocol test
After connecting, type protocol commands and read the replies.
- When to use: When inspecting plain-text service replies.
- What you get: You see the raw response from the server.
- Limitations: Being interactive, it is poor for automation.
Exit
Close the session with quit, or Ctrl+] followed by quit.
- When to use: When cleaning up after a test.
- What you get: The connection closes cleanly.
- Limitations: Some servers keep the connection open.
Installation and usage
Check whether it is installed
telnet -h
sudo apt install telnet
Real-world examples
Port check
Connect to a web port and read the banner.
telnet example.com 80
SMTP test
Read the greeting of a mail server.
telnet mail.example.com 25
See a refusal
A closed port is refused immediately.
telnet 127.0.0.1 9