📄 493-495.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Configuring a TCP/IP Network</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=24//-->
<!--PAGES=493-495//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="491-493.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="495-497.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H3><A NAME="Heading13"></A><FONT COLOR="#000077">Monitoring a TCP/IP Network with <I>netstat</I>
</FONT></H3>
<P>The <TT>netstat</TT> program is an invaluable tool in monitoring your TCP/IP network. It can display the kernel routing table, the status of active network connections, and useful statistics about each network interface. Table 24.6 describes the common command-line arguments for <TT>netstat</TT> ; a few additional arguments are targeted for advanced users. Refer to the man page for more information.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 24.6</B> Common Command-Line Arguments for the netstat Program
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="15%" ALIGN="LEFT">Argument
<TH WIDTH="85%" ALIGN="LEFT">Description
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD VALIGN="TOP"><TT>-a</TT>
<TD>Shows information about all Internet connections, including those that are just listening.
<TR>
<TD VALIGN="TOP"><TT>-i</TT>
<TD>Shows statistics for all network devices.
<TR>
<TD VALIGN="TOP"><TT>-c</TT>
<TD>Shows continually updating network status. This makes <TT>netstat</TT> output a network status listing once per second until it’s interrupted.
<TR>
<TD VALIGN="TOP"><TT>-n</TT>
<TD>Shows remote and local addresses and port information in numeric/raw form rather than resolve host names and service names.
<TR>
<TD VALIGN="TOP"><TT>-o</TT>
<TD>Shows the timer state expiration time and backoff state of each network connection.
<TR>
<TD><TT>-r</TT>
<TD>Shows the kernel routing table.
<TR>
<TD VALIGN="TOP"><TT>-t</TT>
<TD>Shows only TCP socket information, including those that are just listening.
<TR>
<TD><TT>-u</TT>
<TD>Shows only UDP socket information.
<TR>
<TD><TT>-v</TT>
<TD>Shows the version information for <TT>netstat.</TT>
<TR>
<TD><TT>-w</TT>
<TD>Shows raw socket information.
<TR>
<TD><TT>-x</TT>
<TD>Shows UNIX domain socket information.
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077">Displaying Active Network Connections</FONT></H4>
<P>Running <TT>netstat</TT> with no command-line arguments generates a listing of the active network connections on your machine. The following demonstrates the default output from <TT>netstat</TT> :</P>
<!-- CODE //-->
<PRE>
$ <B>netstat</B>
Active Internet connections
Proto Recv-Q Send-Q Local Address Foreign Address (State)
tcp 0 0 linux1.burwell.com:1266 server.burwell.:telnet ESTABLISHED
Active UNIX domain sockets
Proto RefCnt Flags Type State Path
unix 1 [ ACC ] SOCK_STREAM LISTENING /dev/printer
unix 2 [ ] SOCK_STREAM CONNECTED /dev/log
unix 2 [ ] SOCK_STREAM CONNECTED
unix 1 [ ACC ] SOCK_STREAM LISTENING /dev/log
</PRE>
<!-- END CODE //-->
<P>The first section shows an active TCP protocol connection from port 1266 on linux1.burwell.com to the telnet port on server.burwell.com by user burt. Table 24.7 describes the fields in the Active Internet Connections listing.
</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 24.7</B> Active Internet Connection Fields
<TR>
<TH COLSPAN="3"><HR>
<TR>
<TH WIDTH="25%" ALIGN="LEFT">Field
<TH WIDTH="75%" ALIGN="LEFT" COLSPAN="2">Description
<TR>
<TD COLSPAN="3"><HR>
<TR>
<TD><TT>Proto</TT>
<TD COLSPAN="2">The protocol used by this connection, TCP, or UDP.
<TR>
<TD VALIGN="TOP"><TT>Recv-Q</TT>
<TD COLSPAN="2">The number of bytes received on this socket but not yet copied by the user program.
<TR>
<TD VALIGN="TOP"><TT>Send-Q</TT>
<TD COLSPAN="2">The number of bytes sent to the remote host that haven’t been acknowledged.
<TR>
<TD VALIGN="TOP"><TT>Local Address</TT>
<TD COLSPAN="2">Local host name and port number assigned to this connection. The socket IP address is resolved to the canonical host name for that address, and the port number is translated into the service name unless the <TT>-n</TT> flag is used.
<TR>
<TD VALIGN="TOP"><TT>Foreign Address</TT>
<TD COLSPAN="2">The foreign host name and port number assigned to this connection. The <TT>-n</TT> flag affects this field as it does the <TT>Local Address</TT> field.
<TR>
<TD VALIGN="TOP"><TT>State</TT>
<TD COLSPAN="2">The current state of the socket. It can be in one of the following states:<TR>
<TR>
<TD>
<TD WIDTH="25%"><TT>ESTABLISHED</TT>
<TD WIDTH="50%">The connection is fully established.
<TR>
<TD>
<TD VALIGN="TOP"><TT>SYN_SENT</TT>
<TD>The socket is now trying to make a connection to a remote host.
<TR>
<TD>
<TD><TT>SYN_RECV</TT>
<TD>The connection is being initialized.
<TR>
<TD>
<TD VALIGN="TOP"><TT>FIN_WAIT1</TT>
<TD>The socket has been closed and is waiting for the connection to shut down.
<TR>
<TD>
<TD VALIGN="TOP"><TT>FIN_WAIT2</TT>
<TD>The connection has been closed. The socket is waiting for a shutdown from the remote host.
<TR>
<TD>
<TD VALIGN="TOP"><TT>TIME_WAIT</TT>
<TD>The socket is closed and is waiting for a remote host shutdown retransmission.
<TR>
<TD>
<TD><TT>CLOSED</TT>
<TD>The socket isn’t in use.
<TR>
<TD>
<TD VALIGN="TOP"><TT>CLOSE_WAIT</TT>
<TD>The remote host has shut down its connection. The local host is waiting for the socket to close.
<TR>
<TD>
<TD VALIGN="TOP"><TT>LAST_ACK</TT>
<TD>The remote connection is shut down and the socket is closed. The local host is waiting for an acknowledgment.
<TR>
<TD>
<TD VALIGN="TOP"><TT>LISTEN</TT>
<TD>The socket is listening for the incoming connection attempt.
<TR>
<TD>
<TD><TT>UNKNOWN</TT>
<TD>The state of the socket isn’t known.
<TR>
<TD><TT>User</TT>
<TD COLSPAN="2">The login ID of the user who owns the socket.
<TR>
<TD COLSPAN="3"><HR>
</TABLE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="491-493.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="495-497.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -