{"id":93831,"date":"2024-04-18T06:43:11","date_gmt":"2024-04-17T22:43:11","guid":{"rendered":"http:\/\/gulass.cn\/?p=93831"},"modified":"2024-04-18T06:43:11","modified_gmt":"2024-04-17T22:43:11","slug":"three-network-tools","status":"publish","type":"post","link":"https:\/\/gulass.cn\/three-network-tools.html","title":{"rendered":"\u4e09\u6b3e\u8f7b\u91cf\u7ea7Linux \u7f51\u7edc\u76d1\u89c6\u5de5\u5177"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e09\u4e2a Linux \u547d\u4ee4\u4e86\u89e3\u5f53\u524d\u7f51\u7edc\u7684\u5927\u91cf\u4fe1\u606f\u3002iftop \u901a\u8fc7\u8fdb\u7a0b\u53f7\u8ddf\u8e2a\u7f51\u7edc\u8fde\u63a5\uff0cnethogs \u5feb\u901f\u544a\u77e5\u4f60\u54ea\u4e9b\u8fdb\u7a0b\u5728\u5360\u7528\u4f60\u7684\u5e26\u5bbd\uff0c\u800c vnstat \u4ee5\u4e00\u4e2a\u826f\u597d\u7684\u8f7b\u91cf\u7ea7\u5b88\u62a4\u8fdb\u7a0b\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u5e76\u5b9e\u65f6\u8bb0\u5f55\u4f60\u7684\u7f51\u7edc\u4f7f\u7528\u60c5\u51b5\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

iftop<\/strong><\/div>\n

\u4ee4\u4eba\u79f0\u8d5e\u7684 iftop \u53ef\u4ee5\u76d1\u542c\u60a8\u6307\u5b9a\u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u5e76\u4ee5 top \u7684\u6837\u5f0f\u5448\u73b0\u3002<\/p>\n

\u8fd9\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u5c0f\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u4e8e\u627e\u51fa\u7f51\u7edc\u62e5\u585e\uff0c\u6d4b\u901f\u548c\u7ef4\u6301\u7f51\u7edc\u6d41\u91cf\u603b\u91cf\u3002\u770b\u5230\u81ea\u5df1\u5230\u5e95\u5728\u7528\u591a\u5c11\u5e26\u5bbd\u5f80\u5f80\u662f\u975e\u5e38\u60ca\u4eba\u7684\uff0c\u5c24\u5176\u662f\u5bf9\u4e8e\u6211\u4eec\u8fd9\u4e9b\u4ecd\u7136\u8bb0\u5f97\u7535\u8bdd\u7ebf\u8def\u3001\u8c03\u5236\u89e3\u8c03\u5668\uff0c\u201c\u9ad8\u901f\u201d\u5230\u4ee4\u4eba\u60ca\u53eb\u7684 kb \u548c\u5b9e\u65f6\u6ce2\u7279\u7387\u7684\u8001\u4eba\u4eec\u3002\u6211\u4eec\u5728\u5f88\u4e45\u4e4b\u524d\u5c31\u4e0d\u518d\u4f7f\u7528\u6ce2\u7279\u7387\uff0c\u8f6c\u800c\u949f\u60c5\u4e8e\u6bd4\u7279\u7387\u3002\u6ce2\u7279\u7387\u7528\u4e8e\u8861\u91cf\u4fe1\u53f7\u53d8\u5316\uff0c\u5c3d\u7ba1\u6709\u65f6\u5019\u4e0e\u6bd4\u7279\u7387\u76f8\u540c\uff0c\u4f46\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u5e76\u975e\u5982\u6b64\u3002<\/p>\n

\u5982\u679c\u4f60\u53ea\u6709\u4e00\u4e2a\u7f51\u7edc\u63a5\u53e3\uff0c\u76f4\u63a5\u8fd0\u884c iftop \u5373\u53ef\u3002\u4e0d\u8fc7 iftop \u9700\u8981 root \u6743\u9650\uff1a<\/p>\n

 $ sudo iftop\r\n<\/pre>\n

\u5982\u679c\u4f60\u6709\u591a\u4e2a\u7f51\u7edc\u63a5\u53e3\uff0c\u90a3\u5c31\u6307\u5b9a\u4f60\u8981\u76d1\u63a7\u7684\u63a5\u53e3\uff1a<\/p>\n

 $ sudo iftop -i wlan0\r\n<\/pre>\n

\u5c31\u50cf top \u547d\u4ee4\u4e00\u6837\uff0c\u4f60\u53ef\u4ee5\u5728\u547d\u4ee4\u8fd0\u884c\u65f6\u66f4\u6539\u663e\u793a\u9009\u9879\uff1a<\/p>\n

h\u00a0\u5207\u6362\u5e2e\u52a9\u754c\u9762\u3002\r\nn\u00a0\u662f\u5426\u89e3\u6790\u57df\u540d\u3002\r\ns \u5207\u6362\u6e90\u5730\u5740\u7684\u663e\u793a\uff0cd \u5219\u5207\u6362\u76ee\u7684\u5730\u5740\u7684\u663e\u793a\u3002\r\nS\u00a0\u662f\u5426\u663e\u793a\u7aef\u53e3\u53f7\u3002\r\nN\u00a0\u662f\u5426\u89e3\u6790\u7aef\u53e3\uff1b\u82e5\u5173\u95ed\u89e3\u6790\u5219\u663e\u793a\u7aef\u53e3\u53f7\u3002\r\nt \u5207\u6362\u6587\u672c\u663e\u793a\u754c\u9762\u3002\u9ed8\u8ba4\u7684\u663e\u793a\u65b9\u5f0f\u9700\u8981 ncurses\u3002\u6211\u4e2a\u4eba\u8ba4\u4e3a\u56fe 1 \u7684\u663e\u793a\u65b9\u5f0f\u5728\u7ec4\u7ec7\u6027\u548c\u53ef\u8bfb\u6027\u90fd\u66f4\u52a0\u826f\u597d\u3002\r\np\u00a0\u6682\u505c\u663e\u793a\u66f4\u65b0\u3002\r\nq\u00a0\u9000\u51fa\u7a0b\u5e8f\u3002\r\n<\/pre>\n

\"\"<\/p>\n

\u56fe 1:\u7ec4\u7ec7\u6027\u548c\u53ef\u8bfb\u6027\u826f\u597d\u7684\u6587\u672c\u663e\u793a\u3002<\/em><\/p>\n

\u5f53\u4f60\u5207\u6362\u663e\u793a\u8bbe\u7f6e\u7684\u65f6\u5019\uff0ciftop \u5e76\u4e0d\u4f1a\u4e2d\u65ad\u76d1\u6d4b\u6d41\u91cf\u3002\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u5355\u72ec\u76d1\u6d4b\u4e00\u53f0\u4e3b\u673a\u3002\u800c\u8fd9\u9700\u8981\u8be5\u4e3b\u673a\u7684 IP \u5730\u5740\u548c\u5b50\u7f51\u63a9\u7801\u3002\u73b0\u5728\uff0c\u6211\u5f88\u597d\u5947 Pandora\uff08LCTT \u8bd1\u6ce8\uff1a\u4e00\u5bb6\u7f8e\u56fd\u7684\u7535\u53f0\u516c\u53f8\uff09\u80fd\u7ed9\u6211\u8d2b\u7620\u7684\u5e26\u5bbd\u5e26\u6765\u591a\u5927\u7684\u8d1f\u8f7d\u3002\u56e0\u6b64\u6211\u9996\u5148\u4f7f\u7528 dig \u547d\u4ee4\u627e\u5230\u4ed6\u4eec\u7684 IP \u5730\u5740\uff1a<\/p>\n

$ dig A pandora.com\r\n[...]\r\n;; ANSWER SECTION:\r\npandora.com.            267     IN      A       208.85.40.20\r\npandora.com.            267     IN      A       208.85.40.50\r\n<\/pre>\n

\u90a3\u5b50\u7f51\u63a9\u7801\u5462\uff1fipcalc \u4f1a\u544a\u8bc9\u6211\u4eec\uff1a<\/p>\n

$ ipcalc -b 208.85.40.20\r\nAddress:   208.85.40.20   \r\nNetmask:   255.255.255.0 = 24\r\nWildcard:  0.0.0.255  \r\n=>\r\nNetwork:   208.85.40.0\/24 \r\n<\/pre>\n

\u73b0\u5728\uff0c\u5c06 IP \u5730\u5740\u548c\u5b50\u7f51\u63a9\u7801\u63d0\u4f9b\u7ed9 iftop\uff1a<\/p>\n

$ sudo iftop -F 208.85.<\/span>40.20\/<\/span>24<\/span> -i wlan0\r\n<\/span><\/pre>\n

\u5f88\u68d2\u7684\u4e0d\u662f\u4e48\uff1f\u800c\u6211\u4e5f\u5f88\u60ca\u5947\u5730\u53d1\u73b0\uff0cPandora \u5728\u6211\u7684\u7f51\u7edc\u4e0a\uff0c\u6bcf\u5c0f\u65f6\u5927\u7ea6\u4f7f\u7528 500kb\u3002\u5e76\u4e14\u5c31\u50cf\u5927\u591a\u6570\u6d41\u5a92\u4f53\u670d\u52a1\u4e00\u6837\uff0cPandora \u7684\u6d41\u91cf\u5728\u8fc5\u901f\u589e\u957f\uff0c\u5e76\u4f9d\u9760\u7f13\u5b58\u7a33\u5b9a\u4e0b\u6765\u3002<\/p>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528 -G \u9009\u9879\u5bf9 IPv6 \u5730\u5740\u6267\u884c\u76f8\u540c\u7684\u64cd\u4f5c\u3002\u67e5\u9605\u53cb\u597d\u7684 man \u53ef\u4ee5\u5e2e\u52a9\u4f60\u4e86\u89e3 iftop \u7684\u5176\u4ed6\u529f\u80fd\uff0c\u5305\u62ec\u4f7f\u7528\u4e2a\u4eba\u914d\u7f6e\u6587\u4ef6\u81ea\u5b9a\u4e49\u4f60\u7684\u9ed8\u8ba4\u9009\u9879\uff0c\u4ee5\u53ca\u4f7f\u7528\u81ea\u5b9a\u4e49\u8fc7\u6ee4\uff08\u8bf7\u53c2\u9605\u00a0PCAP-FILTER\u00a0\u6765\u83b7\u53d6\u8fc7\u6ee4\u6307\u5357\uff09\u3002<\/p>\n

nethogs<\/strong><\/div>\n

\u5f53\u4f60\u60f3\u8981\u5feb\u901f\u4e86\u89e3\u662f\u8c01\u5728\u5438\u53d6\u4f60\u7684\u5e26\u5bbd\u7684\u65f6\u5019\uff0cnethogs \u662f\u4e2a\u5feb\u901f\u800c\u7b80\u5355\u7684\u65b9\u6cd5\u3002\u4f60\u9700\u8981\u4ee5 root \u8eab\u4efd\u8fd0\u884c\u5e76\u6307\u5b9a\u8981\u76d1\u542c\u7684\u63a5\u53e3\u3002\u5b83\u4f1a\u7ed9\u4f60\u663e\u793a\u5927\u91cf\u7684\u5e94\u7528\u7a0b\u5e8f\u53ca\u5176\u8fdb\u7a0b\u53f7\uff0c\u6240\u4ee5\u5982\u679c\u4f60\u60f3\u7684\u8bdd\uff0c\u4f60\u53ef\u4ee5\u501f\u6b64\u6740\u6b7b\u4efb\u4e00\u8fdb\u7a0b\u3002<\/p>\n

$ sudo nethogs wlan0\r\nnethogs version 0.8.1\r\nPID USER   PROGRAM              DEV    SENT   RECEIVED       \r\n7690 carla \/usr\/lib\/firefox     wlan0 12.494 556.580 KB\/sec\r\n5648 carla ...\/chromium-browser wlan0  0.052   0.038 KB\/sec\r\nTOTAL                                 12.546 556.618 KB\/sec \r\n<\/pre>\n

nethogs \u5e76\u6ca1\u6709\u591a\u5c11\u9009\u9879\uff1a\u5728 kb\/s\u3001kb\u3001b\u3001mb\u4e4b\u95f4\u5faa\u73af\uff0c\u6309\u63a5\u6536\u548c\u53d1\u9001\u7684\u6570\u636e\u5305\u6392\u5e8f\uff0c\u8c03\u6574\u5237\u65b0\u5ef6\u8fdf\u3002\u5177\u4f53\u8bf7\u770bman nethogs\uff0c\u6216\u8005\u662f\u8fd0\u884c nethogs -h\u3002<\/p>\n

vnstat<\/strong><\/div>\n

vnstat\u662f\u6700\u5bb9\u6613\u4f7f\u7528\u7684\u7f51\u7edc\u6570\u636e\u6536\u96c6\u5de5\u5177\u3002\u5b83\u5341\u5206\u8f7b\u91cf\u5e76\u4e14\u4e0d\u9700\u8981 root \u6743\u9650\u3002\u5b83\u4ee5\u5b88\u62a4\u8fdb\u7a0b\u5728\u540e\u53f0\u8fd0\u884c\uff0c\u56e0\u6b64\u53ef\u4ee5\u5b9e\u65f6\u5730\u8bb0\u5f55\u4f60\u7684\u7f51\u7edc\u6570\u636e\u3002\u5355\u4e2a vnstat \u547d\u4ee4\u5c31\u53ef\u4ee5\u663e\u793a\u6240\u7d2f\u8ba1\u7684\u6570\u636e\u3002<\/p>\n

 \r\n$ vnstat -i wlan0\r\nDatabase updated: Tue Oct 17 08:36:38 2017\r\n   wlan0 since 10\/17\/2017\r\n          rx:  45.27 MiB      tx:  3.77 MiB      total:  49.04 MiB\r\n   monthly\r\n                     rx      |     tx      |    total    |   avg. rate\r\n     ------------------------+-------------+-------------+---------------\r\n       Oct '17     45.27 MiB |    3.77 MiB |   49.04 MiB |    0.28 kbit\/s\r\n     ------------------------+-------------+-------------+---------------\r\n     estimated        85 MiB |       5 MiB |      90 MiB |\r\n   daily\r\n                     rx      |     tx      |    total    |   avg. rate\r\n     ------------------------+-------------+-------------+---------------\r\n         today     45.27 MiB |    3.77 MiB |   49.04 MiB |   12.96 kbit\/s\r\n     ------------------------+-------------+-------------+---------------\r\n     estimated       125 MiB |       8 MiB |     133 MiB |\r\n<\/pre>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5b83\u4f1a\u663e\u793a\u6240\u6709\u7684\u7f51\u7edc\u63a5\u53e3\u3002\u4f7f\u7528 -i \u9009\u9879\u6765\u9009\u62e9\u67d0\u4e2a\u63a5\u53e3\u3002\u4e5f\u53ef\u4ee5\u50cf\u8fd9\u6837\u5408\u5e76\u591a\u4e2a\u63a5\u53e3\u7684\u6570\u636e\uff1a<\/p>\n

$ vnstat -i wlan0+eth0+eth1\r\n<\/pre>\n

\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd9\u51e0\u79cd\u65b9\u5f0f\u8fc7\u6ee4\u6570\u636e\u663e\u793a\uff1a<\/p>\n

-h\u00a0\u6309\u5c0f\u65f6\u663e\u793a\u7edf\u8ba1\u4fe1\u606f\u3002\r\n-d\u00a0\u6309\u5929\u663e\u793a\u7edf\u8ba1\u4fe1\u606f.\r\n-w \u548c -m \u5206\u522b\u6309\u5468\u548c\u6708\u4efd\u6765\u663e\u793a\u7edf\u8ba1\u4fe1\u606f\u3002\r\n\u4f7f\u7528 -l \u9009\u9879\u67e5\u770b\u5b9e\u65f6\u66f4\u65b0\u3002\r\n<\/pre>\n

\u4ee5\u4e0b\u8fd9\u6761\u547d\u4ee4\u5c06\u4f1a\u5220\u9664 wlan1 \u7684\u6570\u636e\u5e93\u5e76\u4e0d\u518d\u76d1\u89c6\u5b83\uff1a<\/p>\n

$ vnstat -i wlan1 --delete\r\n<\/pre>\n

\u800c\u4e0b\u9762\u8fd9\u6761\u547d\u4ee4\u5c06\u4f1a\u4e3a\u4f60\u7684\u4e00\u4e2a\u7f51\u7edc\u63a5\u53e3\u521b\u5efa\u4e00\u4e2a\u522b\u540d\u3002\u8fd9\u4e2a\u4f8b\u5b50\u4f7f\u7528\u4e86 Ubuntu 16.04 \u7684\u4e00\u4e2a\u6709\u7ebf\u63a5\u53e3\u540d\u79f0\uff1a<\/p>\n

$ vnstat -u -i enp0s25 --nick eth0\r\n<\/pre>\n

\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cvnstat \u4f1a\u76d1\u89c6 eth0\u3002\u4f60\u53ef\u4ee5\u5728 \/etc\/vnstat.conf \u5bf9\u5b83\u8fdb\u884c\u4fee\u6539\uff0c\u6216\u8005\u5728\u4f60\u7684\u5bb6\u76ee\u5f55\u4e0b\u521b\u5efa\u4f60\u81ea\u5df1\u7684\u4e2a\u4eba\u914d\u7f6e\u6587\u4ef6\u3002\u8bf7\u53c2\u9605 man vnstat \u4ee5\u83b7\u53d6\u5b8c\u6574\u7684\u6307\u5357\u3002<\/p>\n

\u4f60\u4e5f\u53ef\u4ee5\u5b89\u88c5 vnstati \u6765\u521b\u5efa\u7b80\u5355\u7684\u5f69\u56fe\uff08\u56fe 2\uff09:<\/p>\n

$ vnstati -s -i wlx7cdd90a0a1c2 -o vnstat.png\r\n<\/pre>\n

\"\u56fe<\/p>\n

\u56fe 2:\u4f60\u53ef\u4ee5\u4f7f\u7528vnstati\u6765\u521b\u5efa\u7b80\u5355\u7684\u5f69\u56fe\u3002<\/em><\/p>\n

\u8bf7\u53c2\u9605 man vnstati \u4ee5\u83b7\u53d6\u5b8c\u6574\u7684\u9009\u9879\u3002<\/p>\n

\u6b32\u4e86\u89e3 Linux \u7684\u66f4\u591a\u4fe1\u606f\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b66\u4e60 Linux \u57fa\u91d1\u4f1a\u548c edX \u7684\u514d\u8d39\u8bfe\u7a0b\uff0c\u201cLinux \u5165\u95e8\u201d\u3002<\/em><\/p>\n


\n

via: https:\/\/www.linux.com\/learn\/intro-to-linux\/2017\/10\/3-simple-excellent-linux-network-monitors<\/a><\/p>\n

\u4f5c\u8005\uff1aCARLA SCHRODER<\/a> \u8bd1\u8005\uff1aKeyLD<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-9284-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/gulass.cn\/three-network-tools.html<\/a>\u7f16\u8f91\uff1a\u674e\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u6682\u65e0<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e09\u4e2a Linux \u547d\u4ee4\u4e86\u89e3\u5f53\u524d\u7f51\u7edc\u7684\u5927\u91cf\u4fe1\u606f\u3002iftop \u901a\u8fc7\u8fdb\u7a0b\u53f7\u8ddf\u8e2a\u7f51\u7edc\u8fde\u63a5\uff0cnetho […]<\/p>\n","protected":false},"author":63,"featured_media":93848,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-93831","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/93831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=93831"}],"version-history":[{"count":19,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/93831\/revisions"}],"predecessor-version":[{"id":290914,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/93831\/revisions\/290914"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/93848"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=93831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=93831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=93831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}