{"id":194481,"date":"2020-06-24T09:51:14","date_gmt":"2020-06-24T01:51:14","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=194481"},"modified":"2020-06-23T13:53:15","modified_gmt":"2020-06-23T05:53:15","slug":"watch-tcp-udp","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/watch-tcp-udp.html","title":{"rendered":"\u4f7f\u7528watch\u5b9e\u65f6\u89c2\u5bdfTCP\u548cUDP\u7aef\u53e3"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u8f6f\u4ef6\u65b9\u9762\uff0c\u5c24\u5176\u662f\u5728\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u522b\uff0c\u7aef\u53e3\u662f\u4e00\u79cd\u903b\u8f91\u7ed3\u6784\uff0c\u7528\u4e8e\u6807\u8bc6\u7279\u5b9a\u7684\u8fdb\u7a0b\/\u5e94\u7528\u7a0b\u5e8f\u6216\u7f51\u7edc\u670d\u52a1\u7684\u7c7b\u578b\uff0c\u5e76\u4e14\u5728Linux\u7cfb\u7edf\u4e0a\u8fd0\u884c\u7684\u6bcf\u4e2a\u7f51\u7edc\u670d\u52a1\u90fd\u4f7f\u7528\u7279\u5b9a\u7684\u534f\u8bae\uff08\u6700\u5e38\u89c1\u7684\u662fTCP \uff08\u4f20\u8f93\u63a7\u5236\u534f\u8bae\uff09\u548cUDP\uff08\u7528\u6237\u6570\u636e\u62a5\u534f\u8bae\uff09\uff09\u4ee5\u53ca\u7528\u4e8e\u4e0e\u5176\u4ed6\u8fdb\u7a0b\u6216\u670d\u52a1\u8fdb\u884c\u901a\u4fe1\u7684\u7aef\u53e3\u53f7\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5728\u8fd9\u7bc7\u7b80\u77ed\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u4f7f\u7528Linux\u7cfb\u7edf\u4e0a\u7684\u5957\u63a5\u5b57\u6458\u8981\u5b9e\u65f6\u5217\u51fa\u548c\u76d1\u89c6\u6216\u76d1\u89c6\u6b63\u5728\u8fd0\u884c\u7684TCP\u548cUDP\u7aef\u53e3\u3002<\/p>\n

\u5217\u51faLinux\u4e2d\u7684\u6240\u6709\u5f00\u653e\u7aef\u53e3<\/strong><\/div>\n

\u8981\u5217\u51faLinux\u7cfb\u7edf\u4e0a\u7684\u6240\u6709\u6253\u5f00\u7684\u7aef\u53e3\uff0c\u53ef\u4ee5\u4f7f\u7528netstat\u547d\u4ee4\u6216ss\u5b9e\u7528\u7a0b\u5e8f\uff0c\u5982\u4e0b\u6240\u793a\u3002<\/p>\n

\u540c\u6837\u91cd\u8981\u7684\u662f\u8981\u63d0\u5230netstat\u547d\u4ee4\u5df2\u88ab\u5f03\u7528\uff0c\u800css\u547d\u4ee4\u4ee3\u66ff\u4e86\u663e\u793a\u66f4\u8be6\u7ec6\u7684\u7f51\u7edc\u7edf\u8ba1\u4fe1\u606f\u3002<\/p>\n

sudo netstat -tulpn<\/pre>\n

\u6216\u8005<\/p>\n

sudo ss -tulpn<\/pre>\n

\"\"<\/p>\n

\u4ece\u4ee5\u4e0a\u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\uff0c\u201cState\u201d\u5217\u663e\u793a\u7aef\u53e3\u662f\u5426\u5904\u4e8e\u4fa6\u542c\u72b6\u6001\uff08LISTEN\uff09\u3002<\/p>\n

\u5728\u4e0a\u9762\u7684\u547d\u4ee4\u4e2d\uff0c\u6807\u5fd7\uff1a<\/p>\n

    \n
  • -t \u2013 \u542f\u7528TCP\u7aef\u53e3\u5217\u8868\u3002<\/li>\n
  • -u \u2013 \u542f\u7528UDP\u7aef\u53e3\u5217\u8868\u3002<\/li>\n
  • -l \u2013 \u4ec5\u6253\u5370\u76d1\u542c\u5957\u63a5\u5b57\u3002<\/li>\n
  • -n \u2013 \u663e\u793a\u7aef\u53e3\u53f7\u3002<\/li>\n
  • -p \u2013 \u663e\u793a\u8fdb\u7a0b\/\u7a0b\u5e8f\u540d\u79f0\u3002<\/li>\n<\/ul>\n
    \u5b9e\u65f6\u89c2\u5bdfTCP\u548cUDP\u5f00\u653e\u7aef\u53e3<\/strong><\/div>\n

    \u4f46\u662f\uff0c\u8981\u5b9e\u65f6\u76d1\u89c6TCP\u548cUDP\u7aef\u53e3\uff0c\u53ef\u4ee5\u4f7f\u7528\u6240\u793a\u7684watch\u5b9e\u7528\u7a0b\u5e8f\u8fd0\u884cnetstat\u6216ss\u5de5\u5177\u3002<\/p>\n

    sudo watch netstat -tulpn<\/pre>\n

    \u6216\u8005\uff1a<\/p>\n

    sudo watch ss -tulpn<\/pre>\n

    \"\"<\/p>\n

    \u8981\u9000\u51fa\uff0c\u8bf7\u6309Ctrl + C<\/strong>\u3002<\/p>\n

    OK\uff0c\u5230\u76ee\u524d\u4e3a\u6b62\u5c31\u8fd9\u6837\u4e86\uff01 \u5982\u679c\u60a8\u5bf9\u6b64\u6587\u6709\u4efb\u4f55\u7591\u95ee\u6216\u60f3\u6cd5\uff0c\u8bf7\u901a\u8fc7\u4e0b\u9762\u7684\u8bc4\u8bba\u90e8\u5206\u4e0e\u6211\u4eec\u8054\u7cfb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u5728\u8fd9\u7bc7\u7b80\u77ed\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u5411\u60a8\u5c55\u793a\u5982\u4f55\u4f7f\u7528Linux\u7cfb\u7edf\u4e0a\u7684\u5957\u63a5\u5b57\u6458\u8981\u5b9e\u65f6\u5217\u51fa\u548c\u76d1\u89c6\u6216\u76d1\u89c6\u6b63\u5728\u8fd0\u884c\u7684TCP\u548cU […]<\/p>\n","protected":false},"author":317,"featured_media":169260,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-194481","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=194481"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194481\/revisions"}],"predecessor-version":[{"id":194485,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194481\/revisions\/194485"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/169260"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=194481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=194481"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=194481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}