{"id":211113,"date":"2021-02-18T09:07:24","date_gmt":"2021-02-18T01:07:24","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=211113"},"modified":"2021-02-02T16:43:26","modified_gmt":"2021-02-02T08:43:26","slug":"linux-netstat-check","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-netstat-check.html","title":{"rendered":"\u804a\u804alinux\u67e5\u770b\u670d\u52a1\u548c\u7aef\u53e3\u72b6\u6001\u547d\u4ee4netstat"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u4f7f\u7528netstat\u547d\u4ee4\u53ef\u4ee5\u67e5\u770blinux\u7cfb\u7edf\u4e2d\u6b63\u5728\u4f7f\u7528\u7684\u670d\u52a1\u548c\u7aef\u53e3\u60c5\u51b5<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u5e38\u89c1\u53c2\u6570<\/strong><\/div>\n -a (all)\u663e\u793a\u6240\u6709\u9009\u9879\uff0c\u9ed8\u8ba4\u4e0d\u663e\u793aLISTEN\u76f8\u5173 -p \u663e\u793a\u5efa\u7acb\u76f8\u5173\u94fe\u63a5\u7684\u7a0b\u5e8f\u540d \u63d0\u793a\uff1aLISTEN\u548cLISTENING\u7684\u72b6\u6001\u53ea\u6709\u7528-a\u6216\u8005-l\u624d\u80fd\u770b\u5230<\/p>\n \u5b9e\u7528\u547d\u4ee4\u5b9e\u4f8b<\/strong><\/div>\n 1. \u5217\u51fa\u6240\u6709\u7aef\u53e3 (\u5305\u62ec\u76d1\u542c\u548c\u672a\u76d1\u542c\u7684)<\/p>\n <\/p>\n 2. \u5217\u51fa\u6240\u6709\u5904\u4e8e\u76d1\u542c\u72b6\u6001\u7684 Sockets<\/p>\n \u53ea\u663e\u793a\u76d1\u542c\u7aef\u53e3 netstat -l<\/p>\n <\/p>\n \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c tcp \u7aef\u53e3 netstat -lt<\/p>\n <\/p>\n \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c udp \u7aef\u53e3 netstat -lu<\/p>\n <\/p>\n \u53ea\u5217\u51fa\u6240\u6709\u76d1\u542c UNIX \u7aef\u53e3 netstat -lx<\/p>\n <\/p>\n 3. \u663e\u793a\u6bcf\u4e2a\u534f\u8bae\u7684\u7edf\u8ba1\u4fe1\u606f<\/p>\n \u663e\u793a\u6240\u6709\u7aef\u53e3\u7684\u7edf\u8ba1\u4fe1\u606f netstat -s <\/p>\n 4.\u5728 netstat \u8f93\u51fa\u4e2d\u663e\u793a PID \u548c\u8fdb\u7a0b\u540d\u79f0 netstat -p<\/p>\n 5. \u4e0d\u663e\u793a\u4e3b\u673a\uff0c\u7aef\u53e3\u548c\u7528\u6237\u540d (host, port or user)<\/p>\n \u5f53\u4f60\u4e0d\u60f3\u8ba9\u4e3b\u673a\uff0c\u7aef\u53e3\u548c\u7528\u6237\u540d\u663e\u793a\uff0c\u4f7f\u7528 netstat -n\u3002\u5c06\u4f1a\u4f7f\u7528\u6570\u5b57\u4ee3\u66ff\u90a3\u4e9b\u540d\u79f0\u3002<\/p>\n <\/p>\n 6. \u6301\u7eed\u8f93\u51fa netstat \u4fe1\u606f<\/p>\n netstat \u5c06\u6bcf\u9694\u4e00\u79d2\u8f93\u51fa\u7f51\u7edc\u4fe1\u606f\u3002netstat -c<\/p>\n 7. \u663e\u793a\u6838\u5fc3\u8def\u7531\u4fe1\u606f netstat -r<\/p>\n <\/p>\n 8. \u627e\u51fa\u7a0b\u5e8f\u8fd0\u884c\u7684\u7aef\u53e3<\/p>\n \u5e76\u4e0d\u662f\u6240\u6709\u7684\u8fdb\u7a0b\u90fd\u80fd\u627e\u5230\uff0c\u6ca1\u6709\u6743\u9650\u7684\u4f1a\u4e0d\u663e\u793a\uff0c\u4f7f\u7528 root \u6743\u9650\u67e5\u770b\u6240\u6709\u7684\u4fe1\u606f\u3002<\/p>\n netstat -ap | grep ssh<\/pre>\n |