Telnet and netstat commands

Source: Internet
Author: User
Tags close close telnet program

Telnet command details

In addition to the example of how Telnet works, Telnet has many features. Telnet can send any character except "escape" to the remote host. Because the "escape" character is a special command mode of the client in Telnet, its default value is "Ctrl-]". But be sure not to confuse it with the ESC key on the keyboard. We can set "escape" to any character, but it is impossible for telnet to transmit this character to the remote host, the ESC key is a non-printable character. telnet uses it to delete commands in the remote system. Remember that the "escape" character is not always expressed as "Ctrl.

You can simply type telnet without machine words. In this case, telnet> is displayed, indicating that telnet is waiting for a command, such as a question mark "? "A useful command table is obtained:

TELNET :?

Commands may be abbreviated, command are:

Open connect to a site

Close close currect connection

Quit exit Telnet

Display display Operating Parameters

Send transmit special characters ('send? 'For more)

Set set operating parameters ('set? 'For more)

Status print status information

Toggle toggle operating parameters ('toggle? 'For more)

Mode try to enter line-by-line or character-at-a-time mode

? Print help information

Although there are many commands and even sub-commands, only some are commonly used. We will introduce the following:

Close:

This command terminates the connection. It can automatically disconnect from the remote system, or use it to exit Telnet. This command can be used if you want to quit when you enter a network host.

Open:

It is used to connect to a named machine, and the name or IP address of the target machine must be given. If no machine name is provided, Telnet selects a machine name. Note that you should use "close" to close any existing connection before using the "open" command.

Set ECHO:

The local response is on or off. Whether to display the output content on the screen. It is basically the same as DoS echo. If the machine is on ECHO on and you want to change it to off, You can input set echo and change it back to echo off. Then you can type set echo. (This is short. If you have any questions, contact me)

Set escape CHAR:

Create a "escape" character to a special symbol. to replace it with a certain control symbol, you can use "asis" or enter the symbol "^" and add the letter B (for example: ^ B ). During normal operation, the character "escape" is not required, and the symbol used as "escape" cannot be used again. This is similar to setting the true meaning of each key on the keyboard in many programs. However, if you are running a daisy-chained application system, it is useful to re-determine the features of the "escape" character. For example, use Telnet from system A to system B, and then use Telnet to register and enter system C. If a fault occurs when the system is working on system C, when the "escape" symbol is the same, the connection between system B and system C cannot be interrupted. Enter the "escape" identifier, which is always in the command mode of system. If different "escape" symbols are used in each Telnet part, you can select one of the command modes by typing an appropriate symbol, this can also be used in other applications (such as terminal simulation ).

Quit:

Use it to smoothly launch the telnet program.

Z:

Retain telnet, but temporarily return to the local system to execute other commands. Connections in Telnet and other options are retained when telnet is restored.

Carriage Return:

Returns a command from the command mode to the connected remote machine. In addition, there are many other commands that can launch the command mode. The following example shows how to enter porky.math.ukans.edu from registration, enter the command mode, and return Porky ::

Telnet porky.math.ukans.edu

Trying 129.237.128.11...

Connected to porky.math.ukans.edu.

Escape Character is '^]'.

SunOS Unix (Porky)

Login: WL

Password:

Last login: Tue Mar 28 05:35 from ns.bta.net.cn

SunOS release 4.1.3 _ U1 (slippery1) #3: Sun Nov 20 23:47:23 CST 1999

No match.

If: expression syntax.

Porky/serv/WL % Cd/
Porky/% Ctrl-]

TELNET :?

Commands may be abbreviated, command are:

Open connect to a site

Close close currect connection

Quit exit Telnet

Display display Operating Parameters

Send transmit special characters ('send? 'For more)

Set set operating parameters ('set? 'For more)

Status print status information

Toggle toggle operating parameters ('toggle? 'For more)

Mode try to enter line-by-line or character-at-a-time mode

? Print help information

TELNET: Set escape ^ B

Escape Character is '^ B'

Porky/% logout

Ns.bta.net.cn %

Note: The SET command can also exit the command mode. Of course, if not, you can press enter to enter an empty line and return to Porky.

Netstat command details

The netstat command is a very useful tool for monitoring TCP/IP networks. It displays the route table, the actual network connection, and the status information of each network interface device, after netstat is executed on my computer, the output result is:
Active Internet connections (W/O servers)
PROTO Recv-Q send-Q local address foreign address State
TCP 0 2 210.34.6.89: Telnet 210.34.6.96: 2873 established
TCP 296 0 210.34.6.89: 1165 210.34.6.84: NetBIOS-SSN established
TCP 0 0 localhost. localdom: 9001 localhost. localdom: 1162 established
TCP 0 0 localhost. localdom: 1162 localhost. localdom: 9001 established
TCP 0 80 210.34.6.89: 1161 210.34.6.10: NetBIOS-SSN close
Active Unix domain sockets (W/O servers)
PROTO refcnt flags type state I-Node path
UNIX 1 [] stream connected 16178 @ 000000dd
UNIX 1 [] stream connected 16176 @ 000000dc
For Unix 9 [] dgram 5292/dev/log
UNIX 1 [] stream connected 16182 @ 000000df
The output result of netstat can be divided into two parts: active Internet connections (active TCP connection) and active Unix domain sockets (Active Unix domain ETS. In the above output results, the first part has five output results, showing the active TCP connection, and the second part shows the connection of the UNIX domain interface. PROTO displays the protocol used for the connection; refcnt indicates the process number connected to the current interface; types indicates the type of the interface set; State indicates the current status of the interface set; path indicates the path name used by other processes connected to the set interface.
In fact, netstat is a summary of several tools.
◆ Display route table
When calling n e t s t a t along with the-r tag, the kernel route table is displayed, just like using the R o u t e command. The output is as follows:
[Root @ machine1/] $ netstat-NR
Kernel IP routing table
Destination gateway genmask flags MSS window irtt iface
210.34.6.0 0.0.0.0 255.255.255.128 u 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 u 0 0 0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 u 0 0 0 Lo
0.0.0.0 210.34.6.2 0.0.0.0 ug 0 0 0 eth0
The-N option allows netstat to output IP addresses in four periods, instead of symbolic host names and network names. This is especially useful if you want to avoid finding addresses through the network (such as avoiding DNS or NIS servers.
In the netstat output result, the second column displays the gateway specified by the route entry. If no gateway is used, an asterisk (*) or 0.0.0.0 is displayed. The third column displays the overview of the route, when finding the most appropriate route for the specific I P address, the kernel will view all entries in the route table, before comparing the found route with the target route, the I P address and genmask are calculated by bit "and". The fourth column shows different tags, which are described as follows:
■ G routing will adopt a gateway.
■ The interface U is going to use is in the "active" status.
■ H through this route, only one host can be reached.
■ D if the route table entry is generated by an ICMP redirection message, this flag is set.
■ M this flag is set if the route table entry has been modified by the ICMP redirection message.
Iface in the netstat output result shows the physical network adapter used for the connection. For example, eth0 indicates the first and eth1 indicates the second.
◆ Display interface features
When called along with the-I tag, netstat displays the current configuration features of the network interface. In addition, if the-A option is also included in the call, it will also output all the interfaces in the kernel, not just the interfaces currently configured. The output result of netstat-I is as follows:
[Root @ machine1/] $ netstat-I
Kernel interface table
Iface MTU met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR flg
Eth0 1500 0 787165 0 0 1 51655 0 0 0 bru
Eth1 1500 0 520811 0 0 0 1986 0 0 0 bru
Lo 3924 0 1943 0 0 43 0 0 LRU
The MTU and met fields indicate the MTU and measurement value of the interface. The RX and TX columns indicate the number of packets that have been sent and received accurately (RX-OK/TX-OK), produced how many errors (RX-ERR/TX-ERR), dropped how many packets (RX-DRP/TX-DRP), lost due to errors (RX-OVR/TX-OVR ); the last column shows the tags set for this interface. When using ifconfig to display interface configuration, these tags all use one letter. They are described as follows:
■ B has set a broadcast address.
■ L this interface is a return device.
■ M receives all data packets (in chaotic mode ).
■ N to avoid tracking.
■ O disables a R p on this interface.
■ P this is a point-to-point link.
■ The R interface is running.
■ The U Interface is in the active state.
◆ Display Link
Netstat supports the set of options used to display active or passive sockets. Options-T,-u,-W, and-x indicate TCP, UDP, raw, and UNIX socket connections respectively. If you also provide a-a mark, it will also display a socket waiting for connection (that is, in listening mode. In this way, you can obtain a server list. All servers currently running in the system will be included.
When netstat-Ta is called, the output result is as follows:
[Root @ machine1/] $ netstat-Ta
Active Internet connections (servers and established)
PROTO Recv-Q send-Q local address foreign address State
TCP 0 2 210.34.6.89: Telnet 210.34.6.96: 2873 established
TCP 0 0 210.34.6.89: 1165 210.34.6.84: NetBIOS-SSN established
TCP 0 0 localhost. localdom: 9001 localhost. localdom: 1162 established
TCP 0 0 localhost. localdom: 1162 localhost. localdom: 9001 established
TCP 0 0 *: 9001 *: * listen
TCP 0 0 *: 6000 *: * listen
TCP 0 0 *: SOCKS *: * listen
TCP 0 80 210.34.6.89: 1161 210.34.6.10: NetBIOS-SSN close
The above output indicates that some servers are waiting for access connection. With the-A option, netstat will display all sockets. You can determine whether a connection is an outbound connection based on the port number. For the caller host, the listed port number should always be an integer, and for the caller who knows that the well known service port is in use, netstat uses a symbolic service name from the/etc/services file.

Descriptions of netstat statuses

Run the netstat-An command to view details! Next, stat has some English letters. Let's briefly describe what these English letters represent ~

Listen: listens for connection requests from remote TCP ports

SYN-SENT: wait for a matched connection request after sending a connection request again

SYN-RECEIVED: Wait for the other party to confirm the connection request after receiving and sending a connection request

Established: indicates an opened connection.

Fin-wait-1: waiting for confirmation of the remote TCP connection interruption request or previous connection interruption request

Fin-wait-2: Waiting for connection interruption requests from remote TCP

Close-Wait: Waiting for connection interruption requests from Local Users

Closing: waiting for confirmation of remote TCP connection interruption

LAST-ACK: waiting for confirmation of the original connection interruption request sent to remote TCP

Time-Wait: Wait for enough time to confirm that the remote TCP receives the connection interruption request.

Closed: No connection status

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.