linux下常用网络命令总结 【百科全说】-凯发k8官方旗舰厅

腾讯视频/爱奇艺/优酷/外卖 充值4折起

你可以使用以下任何一个命令:

nstat 命令 : 网络统计工具

键入以下命令:

代码如下:

# nstat

输出样例:

#kernel

ipinreceives 133243 0.0

ipindelivers 133243 0.0

ipoutrequests 92904 0.0

icmpouterrors 97 0.0

icmpouttimeexcds 97 0.0

icmpmsgouttype3 97 0.0

tcpactiveopens 538 0.0

tcpestabresets 56 0.0

tcpinsegs 129837 0.0

tcpoutsegs 89720 0.0

tcpretranssegs 42 0.0

tcpoutrsts 704 0.0

udpindatagrams 3255 0.0

udpnoports 97 0.0

udpoutdatagrams 3270 0.0

ip6outnoroutes 206 0.0

tcpexttw 141 0.0

tcpextdelayedacks 508 0.0

tcpextdelayedacklocked 1 0.0

tcpextdelayedacklost 42 0.0

tcpexttcphphits 117659 0.0

tcpexttcppureacks 2158 0.0

tcpexttcphpacks 605 0.0

tcpexttcpsackrecovery 1 0.0

tcpexttcplossundo 16 0.0

tcpexttcpsackfailures 4 0.0

tcpexttcpfastretrans 1 0.0

tcpexttcpslowstartretrans 3 0.0

tcpexttcptimeouts 33 0.0

tcpexttcpdsackoldsent 40 0.0

tcpexttcpdsackrecv 5 0.0

tcpexttcpabortondata 120 0.0

tcpexttcpabortonclose 55 0.0

tcpexttcpsackshiftfallback 9 0.0

ipextinoctets 180131682 0.0

ipextoutoctets 7289106 0.0

ss 命令 : 查询套接字工具

要查看统计汇总, 输入:

代码如下:

# ss -s

输出样例:

total: 786 (kernel 804)

tcp: 65 (estab 40, closed 7, orphaned 0, synrecv 0, timewait 6/0), ports 56

transport total ip ipv6

* 804 - -

raw 1 1 0

udp 12 9 3

tcp 58 52 6

inet 71 62 9

frag 0 0 0

netstat 命令 : 不错的显示套接字信息的旧工具

查看所有网络端口以及汇总信息表,输入:

代码如下:

# netstat -i

输出样例:

kernel interface table

iface mtu met rx-ok rx-err rx-drp rx-ovr tx-ok tx-err tx-drp tx-ovr flg

eth0 1500 0 941022 0 0 0 688165 0 0 0 bmru

lo 16436 0 9304 0 0 0 9304 0 0 0 lru

ppp0 1496 0 3784 0 0 0 4177 0 0 0 mopru

查看每个协议的汇总统计信息,输入:

代码如下:

# netstat -s

输出样例:

ip:

1092065 total packets received

0 forwarded

0 incoming packets discarded

1091681 incoming packets delivered

798913 requests sent out

895 dropped because of missing route

759 reassemblies required

375 packets reassembled ok

icmp:

17 icmp messages received

0 input icmp message failed.

icmp input histogram:

timeout in transit: 8

echo replies: 9

1747 icmp messages sent

0 icmp messages failed

icmp output histogram:

destination unreachable: 1730

echo request: 17

icmpmsg:

intype0: 9

intype11: 8

outtype3: 1730

outtype8: 17

tcp:

4822 active connections openings

1129 passive connection openings

457 failed connection attempts

165 connection resets received

7 connections established

1062519 segments received

771394 segments send out

7158 segments retransmited

6 bad segments received.

2578 resets sent

udp:

20846 packets received

1730 packets to unknown port received.

0 packet receive errors

19242 packets sent

udplite:

tcpext:

71 invalid syn cookies received

8 resets received for embryonic syn_recv sockets

142 packets pruned from receive queue because of socket buffer overrun

2109 tcp sockets finished time wait in fast timer

84 packets rejects in established connections because of timestamp

19454 delayed acks sent

6 delayed acks further delayed because of locked socket

quick ack mode was activated 7306 times

1 packets directly queued to recvmsg prequeue.

1 bytes directly received in process context from prequeue

823921 packet headers predicted

24412 acknowledgments not containing data payload received

10150 predicted acknowledgments

242 times recovered from packet loss by selective acknowledgements

33 congestion windows recovered without slow start by dsack

335 congestion windows recovered without slow start after partial ack

336 tcp data loss events

tcplostretransmit: 35

1 timeouts after reno fast retransmit

156 timeouts after sack recovery

116 timeouts in loss state

461 fast retransmits

5 forward retransmits

608 retransmits in slow start

2073 other tcp timeouts

62 sack retransmits failed

43074 packets collapsed in receive queue due to low socket buffer

8499 dsacks sent for old packets

101 dsacks sent for out of order packets

308 dsacks received

9 dsacks for out of order packets received

427 connections reset due to unexpected data

122 connections reset due to early user close

28 connections aborted due to timeout

tcpdsackignoredold: 3

tcpdsackignorednoundo: 60

tcpspuriousrtos: 4

tcpsackshifted: 282

tcpsackmerged: 740

tcpsackshiftfallback: 1017

ipext:

inmcastpkts: 47

outmcastpkts: 51

inbcastpkts: 1

inoctets: 1341508973

outoctets: 72525352

inmcastoctets: 8649

outmcastoctets: 7519

inbcastoctets: 328

ip / ifconfig 命令 : 配置或者显示网络端口信息

键入以下命令:

代码如下:

# ifconfig

或者

复制代码

代码如下:

# /sbin/ifconfig

或者

代码如下:

# ifconfig eth0

eth0 link encap:ethernet hwaddr b8:ac:6f:65:31:e5

inet addr:192.168.1.5 bcast:192.168.1.255 mask:255.255.255.0

inet6 addr: fe80::baac:6fff:fe65:31e5/64 scope:link

up broadcast running multicast mtu:1500 metric:1

rx packets:966334 errors:0 dropped:0 overruns:0 frame:0

tx packets:703297 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

rx bytes:1186255648 (1.1 gib) tx bytes:73968238 (70.5 mib)

interrupt:17

lo link encap:local loopback

inet addr:127.0.0.1 mask:255.0.0.0

inet6 addr: ::1/128 scope:host

up loopback running mtu:16436 metric:1

rx packets:9666 errors:0 dropped:0 overruns:0 frame:0

tx packets:9666 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

rx bytes:1399578 (1.3 mib) tx bytes:1399578 (1.3 mib)

ppp0 link encap:point-to-point protocol

inet addr:10.1.11.70 p-t-p:10.0.31.18 mask:255.255.255.255

up pointopoint running noarp multicast mtu:1496 metric:1

rx packets:3784 errors:0 dropped:0 overruns:0 frame:0

tx packets:4177 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:3

rx bytes:2400265 (2.2 mib) tx bytes:275983 (269.5 kib)

显示网络端口统计信息,输入:

代码如下:

# ip -s link

输出样例:

1: lo: mtu 16436 qdisc noqueue state unknown

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

rx: bytes packets errors dropped overrun mcast

1444187 9960 0 0 0 0

tx: bytes packets errors dropped carrier collsns

1444187 9960 0 0 0 0

2: eth0: mtu 1500 qdisc mq state up qlen 1000

link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff

rx: bytes packets errors dropped overrun mcast

1221956483 991501 0 0 0 24

tx: bytes packets errors dropped carrier collsns

75623937 720272 0 0 0 0

3: wlan0: mtu 1500 qdisc noop state down qlen 1000

link/ether 00:21:6a:ca:9b:10 brd ff:ff:ff:ff:ff:ff

rx: bytes packets errors dropped overrun mcast

0 0 0 0 0 0

tx: bytes packets errors dropped carrier collsns

0 0 0 0 0 0

4: pan0: mtu 1500 qdisc noop state down

link/ether 4a:c7:5f:0e:8e:d8 brd ff:ff:ff:ff:ff:ff

rx: bytes packets errors dropped overrun mcast

0 0 0 0 0 0

tx: bytes packets errors dropped carrier collsns

0 0 0 0 0 0

8: ppp0: mtu 1496 qdisc pfifo_fast state unknown qlen 3

link/ppp

rx: bytes packets errors dropped overrun mcast

2419881 3848 0 0 0 0

tx: bytes packets errors dropped carrier collsns

284151 4287 0 0 0 0

sar 命令: 显示网络统计信息

输入以下命令 (你需要 通过sysstat包安装并启用sar):

代码如下:

sar -n dev

linux 2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz) tuesday 13 march 2012 _x86_64_ (2 cpu)

12:00:01 cdt iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

12:10:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

12:10:01 cdt eth0 127.13 121.32 95.45 18.34 0.00 0.00 0.00

12:10:01 cdt eth1 98.48 110.62 16.72 96.33 0.00 0.00 0.00

12:20:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

12:20:01 cdt eth0 139.95 133.41 106.30 19.95 0.00 0.00 0.00

12:20:01 cdt eth1 110.65 121.85 18.14 107.13 0.00 0.00 0.00

12:30:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

12:30:01 cdt eth0 147.85 132.49 115.78 20.45 0.00 0.00 0.00

12:30:01 cdt eth1 111.88 127.39 18.61 117.65 0.00 0.00 0.00

12:40:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

12:40:01 cdt eth0 136.75 124.64 105.24 19.48 0.00 0.00 0.00

12:40:01 cdt eth1 101.65 115.32 17.58 104.50 0.00 0.00 0.00

12:50:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

12:50:01 cdt eth0 131.45 125.69 96.49 19.58 0.00 0.00 0.00

12:50:01 cdt eth1 101.41 111.31 17.54 96.78 0.00 0.00 0.00

01:00:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:00:01 cdt eth0 140.30 133.27 102.17 20.75 0.00 0.00 0.00

01:00:01 cdt eth1 106.90 119.51 18.53 103.09 0.00 0.00 0.00

01:10:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:10:01 cdt eth0 152.03 127.74 125.56 19.85 0.00 0.00 0.00

01:10:01 cdt eth1 115.60 134.57 18.73 126.96 0.00 0.00 0.00

01:20:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:20:01 cdt eth0 138.55 130.55 103.03 20.20 0.00 0.00 0.00

....

..

....

..

.

01:00:01 cdt eth1 156.82 169.48 28.83 138.49 0.00 0.00 0.00

01:10:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:10:01 cdt eth0 215.19 194.82 163.11 30.99 0.00 0.00 0.00

01:10:01 cdt eth1 162.49 183.79 28.36 163.70 0.00 0.00 0.00

01:20:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:20:01 cdt eth0 200.20 192.23 140.64 30.93 0.00 0.00 0.00

01:20:01 cdt eth1 153.60 166.96 27.32 140.26 0.00 0.00 0.00

01:30:01 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:30:01 cdt eth0 111.98 103.58 79.12 16.52 0.00 0.00 0.48

01:30:01 cdt eth1 87.50 95.58 14.74 79.35 0.00 0.00 0.00

average: iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

average: eth0 211.21 196.20 156.18 31.20 0.00 0.00 0.01

average: eth1 159.10 174.52 28.00 149.95 0.00 0.00 0.00

或者输入以下命令:

代码如下:

# sar -n dev 1 3

输出样例:

linux 2.6.32-220.2.1.el6.x86_64 (www.cyberciti.biz) tuesday 13 march 2012 _x86_64_ (2 cpu)

01:44:03 cdt iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

01:44:04 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:44:04 cdt eth0 161.70 154.26 105.20 26.63 0.00 0.00 0.00

01:44:04 cdt eth1 145.74 142.55 25.11 144.94 0.00 0.00 0.00

01:44:04 cdt iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

01:44:05 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:44:05 cdt eth0 162.14 156.31 107.46 42.18 0.00 0.00 0.00

01:44:05 cdt eth1 135.92 138.83 39.38 104.92 0.00 0.00 0.00

01:44:05 cdt iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

01:44:06 cdt lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

01:44:06 cdt eth0 303.92 293.14 272.91 37.40 0.00 0.00 0.00

01:44:06 cdt eth1 252.94 290.20 34.87 263.50 0.00 0.00 0.00

average: iface rxpck/s txpck/s rxkb/s txkb/s rxcmp/s txcmp/s rxmcst/s

average: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00

average: eth0 210.37 202.34 163.19 35.66 0.00 0.00 0.00

average: eth1 178.93 191.64 33.36 171.60 0.00 0.00 0.00

07/16 09:59
1.登录: $export cvsroot=:pserver:username@the_server_name:/home/cvsroot note:pserver是访问方式,如果服务器设置的是口令认证,则是 pserver。 username是 cvs服务器的用户名,可以根据你的设置修改; the_server_name是cvs服务器的名称或者ip地址; /home/cvsroot是你的cvs服务器的cvsroot目录,根据你的cvs服务器设置做修改或者询问管理员. 登陆cvs服务器: $cv
07/17 12:55
linux下测试网络连通性命令是ping,其主要功能就是为了检测主机!
09/22 12:37
“安全第一”对于linux管理界乃至计算机也都是一个首要考虑的问题。加密的安全性依赖于密码本身而非算法!而且,此处说到的安全是指数据的完整性,由此,数据的认证安全和完整性高于数据的私密安全,也就是说数据发送者的不确定性以及数据的完整性得不到保证的话,数据的私密性当无从谈起! 1. 禁止系统响应任何从外部/内部来的ping请求攻击者一般首先通过ping命令检测此主机或者ip是否处于活动状态,如果能够ping通 某个主机或者ip,那么攻击者就认为此系统处于活动状态,继而进行攻击或破坏。如果没
07/13 23:59
windows下的类似linux下的grep命令——findstr 经常用linux下的grep命令,比如: netstat -an|grep 1521 其实windows下也有一个类似的命令findstr,比如: c:/windows/system32>netstat -an|findstr 1521 tcp 0.0.0.0:1521 0.0.0.0:0 listening tcp 192.168.1.100:1521 192.168.1.100:49686 established tc
10/08 04:55
linux 下的 time 命令可以获取命令执行时间,windows 下并没有类似的命令,我们可以自力更生写一个批处理,命名为time.bat。 [plain] @echo off set /a startms=%time:~3,1%*60000 %time:~4,1%*6000 %time:~6,1%*1000 %time:~7,1%*100 %time:~9,1%*10 %time:~10,1% %1 %2 %3 %4 %5 %6 set /a endms =%time:
05/13 04:24
在linux下可以使用blkid命令对查询设备上所采用文件系统类型进行查询.blkid主要用来对系统的块设备(包括交换分区)所使用的文件系统类型.label.uuid等信息进行查询.要使用这个命令必须安装e2fsprogs软件包. 直接使用blkid可列出当前系统中所以已挂载文件系统的类型.默认情况下 lsblk 会将块设备输出为树状格式:name —— 设备的名称maj:min —— linux 操作系统中的每个设备都以一个文件表示,对块(磁盘)设备来说,这里用主次设备编号来描述设备.rm —
03/28 21:59
linux下find命令在目录结构中搜索文件,并执行指定的操作。linux下find命令提供了相当多的查找条件,功能很强大。由于find具有强大的功能,所以它的选项也很多,其中大部分选项都值得我们花时间来了解一下。即使系统中含有网络文件系统( nfs),find命令在该文件系统中同样有效,只你具有相应的权限。 在运行一个非常消耗资源的find命令时,很多人都倾向于把它放在后台执行,因为遍历一个大的文件系统可能会花费很长的时间(这里是指30g字节以上的文件系统)。 1.命令格式: find pat
09/01 06:19
一.更改telnet登录慢的问题: cd /etc vi resolv.conf 将里面内容清空 二.更改root用户不能直接远程登录问题: cd /etc cd pam.d vi login 注释掉这行 #auth required pam_securetty.so //该行注释掉三.挂接usb移动硬盘 将移动硬盘挂上. #df 查看linux下硬盘盘符 mount /dev/sda1 /mnt/usb (举例)四.linux时区同步问题(安装ntp软件过程) 首先在http://www.me
07/04 03:14
对于在教育网内的同学来说,最大的痛苦就是教育网不能出国和访问公网速度 慢了(有钱买流量的不用看本文),所以通常有些需求的就必须购买像教育网 直通车之类的加速服务,当然还有另一种选择那就是花钱买专门的vpn。但这里 都有一个问题,那就是所有的网络加速服务都只有windows下的客户端,在 linux就都没有官方的使用方法了。对有些加速服务,有人想出了一些非官方的 办法,比如在知道服务器地址的前提下,教育网直通车可以用pppoe来连。据说,brigewan也可以用类似的方法,但上次在一个论坛里看到因
网站地图