Today, the editor will share with you the relevant knowledge points about the difference between linux nc and telnet. I hope you will gain something after reading this article. Let's take a look at it together.
The functions implemented by nc and telnet are different: 1. telnet can connect to the server port and communicate; while nc can monitor the server port and communicate with the client ( Can only accept at most one client). 2. telnet can log in to a remote telnet server and use the command line to control it; while nc scans the port of the specified server, and it connects to the remote server as a client for communication.
Introduction to Telnet
The telnet program can directly talk to the web server.
Through telnet, you can open a TCP connection to a certain port on a certain machine, and then directly enter some characters to that port. The web server will handle the telnet program as a web client, and all data sent back to the TCP connection will be displayed on the screen.
telnet www.xxx.com 80
GET /tools.html HTTP/1.1
Host: www.xxx.com
response:
HTTP/1.1 200 OK
DATE: Sun, 01 Oct 2000 23:25:17 GMT
Server: Apache/1.3.11 BSafe-SSL/1.38 (Unix) FrontPage/4.0.4.3
Last-Modified: Tue, 04 Jul 2000 09:46:21 GMT
ETag: "373979-193-3961b26d"
Accept-Ranges: bytes
Content-length: 403
Connection: close
Content-Type: text/html
Tools page
...
Connection closed by foreignhost.
Telnet will look up the hostname and open a connection to the web server listening on port 80 of www.xxx.com.
Telnet can emulate an HTTP client very well, but it cannot be used as a server. And it is very troublesome to automate scripts for telnet. For a more flexible tool, take a look at netcat below. UDP- and TCP-based traffic (including HTTP) can be easily manipulated and scripted by
nc
.
Introduction to Netcat(NC)
Netcat is known as the Swiss Army Knife among network tools. It is a very simple Unix tool that can read and write TCP or UDP network connections (network connection). It's designed to be a solid back-end tool, and you can use it in scripts in a variety of ways by combining and redirecting with other tools. At the same time, it's a feature-rich network debugging and development tool, as it can establish almost any type of connection you might use, as well as some very interesting built-in features. Netcat, whose actual executable name is nc, is a Unix tool that has been provided for a long time but has no published de facto standard. It's amazing what you can do with NC commands.
Netcat can also be used as a server, listening to connection requests (inbound connection) of any specified port, and can do the same read and write operations. Other than minor limitations, it doesn't really care whether it's running in client mode or server mode, it just ships all the data back and forth. In either mode, an inactivity time can be set to forcibly close the connection. It can also complete these functions through UDP, so it is like a UDP program like telnet, used to test your UDP server. As its U refers to, UDP is an unreliable data transport compared to TCP, and some systems have trouble using UDP to transmit large amounts of data, but it has some uses.
What NC does is establish a link between two computers and return two data streams, what you can do after that is up to your imagination. You can set up a server, transfer files, chat with friends, stream media or use it as a standalone client for other protocols.
Main purpose
Generally we use netcat to do the following three things:
1. Scan the specified IP port Situation
2. Port forwarding data (emphasis)
3. Submit custom data package
The difference between nc and telnet
The functions that telnet can realize:
Connect to the server port and communicate
Log in to the remote telnet server and use the command line to control it
Functions that can be realized by nc:
Listen to the server port and communicate with the client (only one client can be received at most)
Connect to the remote server as a client to communicate
Extension Knowledge:
The reason why Telnet fails
1. The problem of telnet service itself: whether the service is enabled
2 , Firewall policy problem: whether the firewall of the system where the telnet service is located is restricted, whether the firewall between the source host and the host providing the telnet service is restricted
3, whether the service restricts ip, and whether the service reaches The maximum number of connections
The reason for the ping failure
1. The server is not started/ip does not exist
2. The network segment is different,
3. The firewall settings filter the ICMP packets sent by ping, resulting in no feedback and time out
4. The IP address is set incorrectly. For multiple network cards For the server, the ip configuration of each network port must not be in the same network segment, otherwise it will cause the route to not know which exit to choose
5, network cable failure
6), The gateway is not set, this is for the small network 128 network segment, if the router is not configured, it will not be able to route
The above is the difference between linux nc and telnet. All the content of this article, thank you for reading ! I believe that everyone has gained a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the Yisu cloud industry information channel.
Copyright Description:No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。
Follow us