Merge pull request #1857 from geekpi/master

translated
This commit is contained in:
geekpi 2014-10-18 13:43:10 +08:00
commit 584c97b676
2 changed files with 65 additions and 65 deletions

View File

@ -1,65 +0,0 @@
Linux ss Tool to Identify Sockets / Network Connections with Examples
================================================================================
ss is part of the iproute2 (utilities for controlling TCP/IP networking and traffic) package. iproute2 is intended to replace an entire suite of standard Unix networking tools (often called "net-tools") that were previously used for the tasks of configuring network interfaces, routing tables, and managing the ARP table. The ss utility is used to dump socket statistics, it allows showing information similar to netstat and its able display more TCP and state information. It should also be faster as it gets its information directly from kernel space. The options used with the ss commands are very similar to netstat making it an easy replacement.
### Usage and common options ###
ss is very similar to netstat, by default it will show you a list of open non-listening TCP sockets that have established connection and you can shape the output with the following options:
- **-n** - Do now try to resolve service names.
- **-r** - Try to resolve numeric address/ports.
- **-a** - Display all sockets.
- **-l** - Display listening sockets.
- **-p** - Show process using socket.
- **-s** - Print summary statistics.
- **-t** - Display only TCP sockets.
- **-u** - Display only UDP sockets.
- **-d** - Display only DCCP sockets.
- **-w** - Display only RAW sockets.
- **-x** - Display only Unix domain sockets.
- **-f FAMILY** - Display sockets of type FAMILY. Currently the following families are supported: unix, inet, inet6, link, netlink.
- **-A QUERY** - List of socket tables to dump, separated by commas. The following identifiers are understood: all, inet, tcp, udp, raw, unix, packet, netlink, unix_dgram, unix_stream, packet_raw, packet_dgram.
### ss command examples ###
**1.** Display all open TCP ports and the process that uses them:
# ss -tnap
![ss tnap](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-tnap.jpg)
**2.** You can use -4 flag to display the IPv4 connections and the -6 flag to display IPv6 connections, for example:
# ss -tnap6
![ss tnap6](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-tnap6.jpg)
**3.** In the same manner, to show all open UDP ports you just have to replace t with n.
# ss -tnap
![ss unap](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-unap.jpg)
**4.** To print various useful statistics you can use the -s flag:
# ss -s
![ss stats](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-stats.jpg)
**5.** To check all connections in a different state you can use the -o flag, for example to display all the established connection:
# ss -tn -o state established -p
![ss est](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-est.jpg)
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/ss-sockets-network-connection/
作者:[Adrian Dinu][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/adriand/

View File

@ -0,0 +1,65 @@
Linux中的鉴别套接字/网络的ss工具示例
================================================================================
ss是iproute2包的一部分控制TCP/IP网络和流量的工具。iproute2目标是替代先前用于配置网络接口路由表和管理ARP表的标准Unix网络工具套装通常称之为“net-tools”。ss工具用于导出套接字统计它可以显示与netstat类似的信息且可以显示更多的TCP和状态信息。它也应该更加快因为它工作与内核空间。ss的操作和netstat很像所以这让它可以很容易就可以取代。
### 使用和常见选项 ###
ss和netstat很像默认他会显示已经建立连接的开放的非监听TCP套接字列表。并且你可以用下面的选项过滤输出
- **-n** - 尝试解析服务名。
- **-r** - 尝试解析数字地址/端口。
- **-a** - 显示所有套接字。
- **-l** - 显示监听套接字。
- **-p** - 显示进程人使用的套接字。
- **-s** - 打印统计
- **-t** - 只显示TCP套接字。
- **-u** - 只显示UDP套接字。
- **-d** - 只显示DCCP套接字
- **-w** - 只显示原始套接字。
- **-x** - 只显示Unix域套接字
- **-f FAMILY** - 显示FAMILY套接字的类型。目前支持下面这些家族unix、inet、inet6、link、netlink。
- **-A QUERY** - 导出套接字列表通过逗号分隔。可以识别下面的标识符all、inet、tcp、udp、raw、unix、packet、netlink、unix_dgram、unix_stream、packet_raw、packet_dgram。
### ss 命令示例 ###
**1.** 显示所有的的TCP端口和使用它们的进程
# ss -tnap
![ss tnap](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-tnap.jpg)
**2.** 你可以使用-4 标志来显示IPv4链接-6标志来显示IPv6链接比如
# ss -tnap6
![ss tnap6](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-tnap6.jpg)
**3.** 跟上面的行为一样你只需用n代替t就会显示所有开放的UDP端口。
# ss -tnap
![ss unap](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-unap.jpg)
**4.** 你可以使用-s标志来打印不同的有用的统计
# ss -s
![ss stats](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-stats.jpg)
**5.** 你可以使用-o标志来检查所有不同状态下的链接比如显示所有已经建立的连接。
# ss -tn -o state established -p
![ss est](http://blog.linoxide.com/wp-content/uploads/2014/09/ss-est.jpg)
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/ss-sockets-network-connection/
作者:[Adrian Dinu][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/adriand/