Telnet is commonly used to check if a TCP connection to a specific port succeeds — essentially testing whether the port is open and reachable. Note that telnet itself is TCP-based, so it cannot test UDP sockets.
Syntax Basic:
telnet [options] host [port]
More complete:
telnet [-8acdEfFKLrx] [-b<host_alias>] [-e<escape_char>] [-k<realm>] [-l<user>] [-n<tracefile>] [-S<tos>] [-X<authtype>] [host [port]]
Quick background Telnet is the classic remote login client based on the TELNET protocol. It lets you run commands on a remote server as if you were sitting in front of it. You log in with username/password, but everything (including credentials) is sent in clear text — very insecure. Most modern Linux servers disable telnet and use SSH instead.
That said, curl can test HTTP services, and telnet can too (more on that below).
For UDP testing, use:
- nc -u
- nmap -sU
- tcpdump
- Application-level tools like dig for DNS
Common options
- -4 Force IPv4
- -6 Force IPv6
- -8 Allow 8-bit data
- -a Attempt automatic login (rarely used now)
- -b<alias> Use alias for host
- -e<char> Set escape character (default Ctrl+]) Example:
telnet -e ^X host port - -l<user> Specify login user (for traditional telnet servers) Example:
telnet -l root 192.168.1.10 - -n<file> Log session to file (great for debugging)
In interactive mode After connecting, press Ctrl+] to enter telnet command mode. Useful commands:
- quit Exit telnet
- close Close current connection
- status Show connection status
- open host port Connect to new host/port
- set localecho Enable local echo
- toggle crlf Toggle CR/LF handling
Examples
- Connect to a remote telnet service
telnet 192.168.120.206
(or by domain: telnet www.baidu.com)
If it fails:
- Check IP/address
- Is the host up?
- Routing correct? (route)
- Is telnet service running? (netstat -tlnp → look for TCP 23 LISTEN)
- Firewall allowing port 23? (iptables -L)
- Test TCP reachability (the 80% use case)
telnet 127.0.0.1 6379
Outcomes:
- Connected → port open and TCP reachable
- Connection refused → port not listening
- Connection timed out → network/firewall issue
- As a generic TCP client Telnet doesn’t care about application protocols — it just sends whatever you type over TCP. Perfect for quick testing of text-based protocols.
HTTP example:
telnet example.com 80
GET / HTTP/1.1
Host: example.com
(then hit Enter twice)
Redis example:
telnet 127.0.0.1 6379
PING
→ +PONG
Typical telnet service config (/etc/xinetd.d/telnet)
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
Restrict access:
only_from = 10.0.0.2
no_access = 10.0.0.{2,3,4}
access_times = 9:00-12:00 13:00-17:00
bind = 10.0.0.2
Limitations
- Clear-text transmission of credentials → never use for real logins in production (use SSH)
- Can’t test UDP
- Binary protocols will garble output → stick to text protocols
Modern role: Telnet is best positioned as a quick TCP port/text-protocol debugging tool, not a login method.
Related tools
- nc/netcat → Swiss army knife for TCP/UDP
- curl → HTTP/HTTPS testing
- ssh → Secure remote login
- nmap → Port scanning (including UDP)

