{"id":326,"date":"2013-08-09T11:37:28","date_gmt":"2013-08-09T11:37:28","guid":{"rendered":"a666587afda6e89aec274a3657558a27"},"modified":"2013-08-09T11:37:28","modified_gmt":"2013-08-09T11:37:28","slug":"","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/326","title":{"rendered":"linux net status SYN_RECV"},"content":{"rendered":"<p><span style=\"font-size:small;\">\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u6765\u7edf\u8ba1\u5f53\u524d\u8fde\u63a5\u6570<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>netstat -n | awk '\/^tcp\/ {++S[$NF]} END {for(a in S) print a, S[a]}'<\/p>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\">\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u8fd9\u6761\u8bed\u53e5\u8fd4\u56de\u7ed3\u679c\u5982\u4e0b<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>&nbsp;<\/p>\n<\/div>\n<div id=\"code740\" class=\"codeText\">\n<ol class=\"dp-css\" style=\"padding-left:40px;margin:0px 1px 0px 0px;\">\n<li>TIME_WAIT 346<\/li>\n<li>FIN_WAIT1 85<\/li>\n<li>FIN_WAIT2 6<\/li>\n<li>ESTABLISHED 1620<\/li>\n<li>SYN_RECV 169<\/li>\n<li>LAST_ACK 8<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">SYN_RECV<span style=\"font-family:\u5b8b\u4f53;\">\u8868\u793a\u6b63\u5728\u7b49\u5f85\u5904\u7406\u7684\u8bf7\u6c42\u6570\uff1b<\/span><span style=\"font-family:'Times New Roman';\">ESTABLISHED<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8868\u793a\u6b63\u5e38\u6570\u636e\u4f20\u8f93\u72b6\u6001\uff1b<\/span><span style=\"font-family:'Times New Roman';\">TIME_WAIT<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8868\u793a\u5904\u7406\u5b8c\u6bd5\uff0c\u7b49\u5f85\u8d85\u65f6\u7ed3\u675f\u7684\u8bf7\u6c42\u6570\u3002<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u72b6\u6001\uff1a\u63cf\u8ff0<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">CLOSED<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u65e0\u8fde\u63a5\u662f\u6d3b\u52a8\u7684\u6216\u6b63\u5728\u8fdb\u884c<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">LISTEN<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u670d\u52a1\u5668\u5728\u7b49\u5f85\u8fdb\u5165\u547c\u53eb<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">SYN_RECV<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u4e00\u4e2a\u8fde\u63a5\u8bf7\u6c42\u5df2\u7ecf\u5230\u8fbe\uff0c\u7b49\u5f85\u786e\u8ba4<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">SYN_SENT<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u5e94\u7528\u5df2\u7ecf\u5f00\u59cb\uff0c\u6253\u5f00\u4e00\u4e2a\u8fde\u63a5<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">ESTABLISHED<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u6b63\u5e38\u6570\u636e\u4f20\u8f93\u72b6\u6001<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">FIN_WAIT1<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u5e94\u7528\u8bf4\u5b83\u5df2\u7ecf\u5b8c\u6210<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">FIN_WAIT2<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u53e6\u4e00\u8fb9\u5df2\u540c\u610f\u91ca\u653e<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">ITMED_WAIT<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u7b49\u5f85\u6240\u6709\u5206\u7ec4\u6b7b\u6389<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">CLOSING<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u4e24\u8fb9\u540c\u65f6\u5c1d\u8bd5\u5173\u95ed<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">TIME_WAIT<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u53e6\u4e00\u8fb9\u5df2\u521d\u59cb\u5316\u4e00\u4e2a\u91ca\u653e<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">LAST_ACK<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u7b49\u5f85\u6240\u6709\u5206\u7ec4\u6b7b\u6389<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u53e6\u5916\u5f88\u591a\u4eba\u4f1a\u7528\u5230<span style=\"font-family:'Times New Roman';\">TCP&nbsp;SYN&nbsp;Flood<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u900f\u8fc7\u7f51\u8def\u5e95\u5c42\u5bf9\u670d\u52a1\u5668<\/span><span style=\"font-family:'Times New Roman';\">Server<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8fdb\u884c\u653b\u51fb\u7684\uff0c\u6211\u53ef\u4ee5\u7528<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">Iptables<span style=\"font-family:\u5b8b\u4f53;\">\u9632\u8303\u4e0b\uff1a<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u9632\u6b62\u540c\u6b65\u5305\u6d2a\u6c34\uff08<span style=\"font-family:'Times New Roman';\">Sync&nbsp;Flood<\/span><span style=\"font-family:\u5b8b\u4f53;\">\uff09<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>&nbsp;<\/p>\n<\/div>\n<div id=\"code369\" class=\"codeText\">\n<ol class=\"dp-css\" style=\"padding-left:40px;margin:0px 1px 0px 0px;\">\n<li>iptables -A FORWARD -p tcp --syn -m limit --limit 1\/s -j ACCEPT<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u4e5f\u6709\u4eba\u5199\u4f5c<\/span><\/p>\n<div>\n<div id=\"code862\" class=\"codeText\">\n<ol class=\"dp-css\" style=\"padding-left:40px;margin:0px 1px 0px 0px;\">\n<li>iptables -A INPUT -p tcp --syn -m limit --limit 1\/s -j ACCEPT<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">--limit&nbsp;1\/s&nbsp;<span style=\"font-family:\u5b8b\u4f53;\">\u9650\u5236<\/span><span style=\"font-family:'Times New Roman';\">syn<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u5e76\u53d1\u6570\u6bcf\u79d2<\/span><span style=\"font-family:'Times New Roman';\">1<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u6b21\uff0c\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u4fee\u6539<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u9632\u6b62\u5404\u79cd\u7aef\u53e3\u626b\u63cf<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>&nbsp;<\/p>\n<\/div>\n<div id=\"code153\" class=\"codeText\">\n<ol class=\"dp-css\" style=\"padding-left:40px;margin:0px 1px 0px 0px;\">\n<li>iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1\/s -j ACCEPT<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">Ping<span style=\"font-family:\u5b8b\u4f53;\">\u6d2a\u6c34\u653b\u51fb\uff08<\/span><span style=\"font-family:'Times New Roman';\">Ping&nbsp;of&nbsp;Death<\/span><span style=\"font-family:\u5b8b\u4f53;\">\uff09<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>&nbsp;<\/p>\n<\/div>\n<div id=\"code949\" class=\"codeText\">\n<ol class=\"dp-css\" style=\"padding-left:40px;margin:0px 1px 0px 0px;\">\n<li>iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1\/s -j ACCEPT<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\">\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">&nbsp;&nbsp;&nbsp; \u540c\u65f6\uff0c\u5728\u521d\u59cb\u5316\u7cfb\u7edf\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u5bf9\u670d\u52a1\u5668\u7684\u6570\u636e\u8fde\u63a5\u505a\u8bbe\u7f6e\uff0c\u4e0b\u9762\u7b80\u5355\u7684\u8bbe\u7f6e\u4e0b\uff0c\u5982\u679c\u6709\u5173\u4e8e\u8fd9\u65b9\u9762\u7684\u8bbe\u7f6e\uff0c\u6b22\u8fce\u5927\u5bb6\u5206\u4eab\u4e0b\uff0c\u5148\u8c22\u8fc7\u4e86<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">...<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">vi<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">m<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">&nbsp;\/etc\/sysctl.conf<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_tw_reuse&nbsp;=&nbsp;1<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u8be5\u6587\u4ef6\u8868\u793a\u662f\u5426\u5141\u8bb8\u91cd\u65b0\u5e94\u7528\u5904\u4e8e<span style=\"font-family:'Times New Roman';\">TIME-WAIT<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u72b6\u6001\u7684<\/span><span style=\"font-family:'Times New Roman';\">socket<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u7528\u4e8e\u65b0\u7684<\/span><span style=\"font-family:'Times New Roman';\">TCP<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8fde\u63a5\u3002<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_tw_recycle&nbsp;=&nbsp;1<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">recyse<span style=\"font-family:\u5b8b\u4f53;\">\u662f\u52a0\u901f<\/span><span style=\"font-family:'Times New Roman';\">TIME-WAIT&nbsp;sockets<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u56de\u6536<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u5bf9<span style=\"font-family:'Times New Roman';\">tcp_tw_reuse<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u548c<\/span><span style=\"font-family:'Times New Roman';\">tcp_tw_recycle<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u7684\u4fee\u6539\uff0c\u53ef\u80fd\u4f1a\u51fa\u73b0<\/span><span style=\"font-family:'Times New Roman';\">.warning,&nbsp;got&nbsp;duplicate&nbsp;tcp&nbsp;line&nbsp;warning,&nbsp;got&nbsp;BOGUS&nbsp;tcp&nbsp;line.<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u4e0a\u9762\u8fd9\u4e8c\u4e2a\u53c2\u6570\u6307\u7684\u662f\u5b58\u5728\u8fd9\u4e24\u4e2a\u5b8c\u5168\u4e00\u6837\u7684<\/span><span style=\"font-family:'Times New Roman';\">TCP<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8fde\u63a5\uff0c\u8fd9\u4f1a\u53d1\u751f\u5728\u4e00\u4e2a\u8fde\u63a5\u88ab\u8fc5\u901f\u7684\u65ad\u5f00\u5e76\u4e14\u91cd\u65b0\u8fde\u63a5\u7684\u60c5\u51b5\uff0c\u800c\u4e14\u4f7f\u7528\u7684\u7aef\u53e3\u548c\u5730\u5740\u76f8\u540c\u3002\u4f46\u57fa\u672c&nbsp;\u4e0a\u8fd9\u6837\u7684\u4e8b\u60c5\u4e0d\u4f1a\u53d1\u751f\uff0c\u65e0\u8bba\u5982\u4f55\uff0c\u4f7f\u80fd\u4e0a\u8ff0\u8bbe\u7f6e\u4f1a\u589e\u52a0\u91cd\u73b0\u673a\u4f1a\u3002\u8fd9\u4e2a\u63d0\u793a\u4e0d\u4f1a\u6709\u4eba\u548c\u5371\u5bb3\uff0c\u800c\u4e14\u4e5f\u4e0d\u4f1a\u964d\u4f4e\u7cfb\u7edf\u6027\u80fd\uff0c\u76ee\u524d\u6b63\u5728\u8fdb\u884c\u5de5\u4f5c<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">&nbsp;net.ipv4.tcp_syncookies&nbsp;=&nbsp;1<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u8868\u793a\u5f00\u542f<span style=\"font-family:'Times New Roman';\">SYN&nbsp;Cookies<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u3002\u5f53\u51fa\u73b0<\/span><span style=\"font-family:'Times New Roman';\">SYN<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u7b49\u5f85\u961f\u5217\u6ea2\u51fa\u65f6\uff0c\u542f\u7528<\/span><span style=\"font-family:'Times New Roman';\">cookies<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u6765\u5904\u7406\uff0c\u53ef\u9632\u8303\u5c11\u91cf<\/span><span style=\"font-family:'Times New Roman';\">SYN<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u653b\u51fb\uff0c\u9ed8\u8ba4\u4e3a<\/span><span style=\"font-family:'Times New Roman';\">0<\/span><span style=\"font-family:\u5b8b\u4f53;\">\uff0c\u8868\u793a\u5173\u95ed\uff1b<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_synack_retries&nbsp;=&nbsp;1<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_keepalive_time&nbsp;=&nbsp;1200<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u8868\u793a\u5f53<span style=\"font-family:'Times New Roman';\">keepalive<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8d77\u7528\u7684\u65f6\u5019<\/span><span style=\"font-family:'Times New Roman';\">,TCP<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u53d1\u9001<\/span><span style=\"font-family:'Times New Roman';\">keepalive<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u6d88\u606f\u7684\u9891\u5ea6\u3002\u7f3a\u7701\u662f<\/span><span style=\"font-family:'Times New Roman';\">2<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u5c0f\u65f6<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_fin_timeout&nbsp;=&nbsp;30<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">fin_wait1<span style=\"font-family:\u5b8b\u4f53;\">\u72b6\u6001\u662f\u5728\u53d1\u8d77\u7aef\u4e3b\u52a8\u8981\u6c42\u5173\u95ed<\/span><span style=\"font-family:'Times New Roman';\">tcp<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8fde\u63a5\uff0c\u5e76\u4e14\u4e3b\u52a8\u53d1\u9001<\/span><span style=\"font-family:'Times New Roman';\">fin<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u4ee5\u540e\uff0c\u7b49\u5f85\u63a5\u6536\u7aef\u56de\u590d<\/span><span style=\"font-family:'Times New Roman';\">ack<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u65f6\u5019\u7684\u72b6\u6001\u3002\u5bf9\u4e8e\u672c\u7aef\u65ad\u5f00\u7684<\/span><span style=\"font-family:'Times New Roman';\">socket<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8fde\u63a5\uff0c<\/span><span style=\"font-family:'Times New Roman';\">TCP<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u4fdd\u6301\u5728<\/span><span style=\"font-family:'Times New Roman';\">FIN-WAIT-2<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u72b6\u6001\u7684\u65f6\u95f4\u3002\u5bf9\u65b9\u53ef\u80fd\u4f1a\u65ad\u5f00\u8fde\u63a5\u6216\u4e00\u76f4\u4e0d\u7ed3\u675f\u8fde\u63a5\u6216\u4e0d\u53ef\u9884\u6599\u7684\u8fdb\u7a0b\u6b7b\u4ea1\u3002<\/span><\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">&nbsp;net.ipv4.ip_local_port_range&nbsp;=&nbsp;1024&nbsp;65000<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_max_syn_backlog&nbsp;=&nbsp;8192<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u8be5\u6587\u4ef6\u6307\u5b9a\u4e86\uff0c\u5728\u63a5\u53e3\u63a5\u6536\u6570\u636e\u5305\u7684\u901f\u7387\u6bd4\u5185\u6838\u5904\u7406\u8fd9\u4e9b\u5305\u7684\u901f\u7387\u5feb\u65f6\uff0c\u5141\u8bb8\u9001\u5230\u961f\u5217\u7684\u6570\u636e\u5305\u7684\u6700\u5927\u6570\u76ee\u3002<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">net.ipv4.tcp_max_tw_buckets&nbsp;=&nbsp;5000<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u4f7f\u8bbe\u7f6e\u751f\u6548<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">sysctl&nbsp;-p<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">&nbsp;&nbsp;<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u53c2\u8003\u8d44\u6599\uff1a<\/span><span><a href=\"http:\/\/blog.sina.com.cn\/s\/blog_416656f70100i08e.html\" target=\"_blank\"><span class=\"15\" style=\"font-size:10pt;font-family:'\u5b8b\u4f53';font-weight:normal;color:#0000ff;text-decoration:underline;mso-spacerun:'yes';\">http:\/\/blog.sina.com.cn\/s\/blog_416656f70100i08e.html<\/span><\/a><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"http:\/\/baike.baidu.com\/view\/1520054.htm\">http:\/\/baike.baidu.com\/view\/1520054.htm<\/a><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\">&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p><span style=\"font-size:small;\">\u53ef\u4ee5\u901a\u8fc7\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4\u6765\u7edf\u8ba1\u5f53\u524d\u8fde\u63a5\u6570<\/span><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\"><br \/>\n<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>netstat -n | awk '\/^tcp\/ {++S[$NF]} END {for(a in S) print a, S[a]}'<\/p>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u8fd9\u6761\u8bed\u53e5\u8fd4\u56de\u7ed3\u679c\u5982\u4e0b<\/span><\/p>\n<div>\n<div class=\"codeheads\">\n<p>&nbsp;<\/p>\n<\/div>\n<div id=\"code740\" class=\"codeText\">\n<ol class=\"dp-css\" style=\"padding-left:40px;margin:0px 1px 0px 0px;\">\n<li>TIME_WAIT 346<\/li>\n<li>FIN_WAIT1 85<\/li>\n<li>FIN_WAIT2 6<\/li>\n<li>ESTABLISHED 1620<\/li>\n<li>SYN_RECV 169<\/li>\n<li>LAST_ACK 8<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<p><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">SYN_RECV<span style=\"font-family:\u5b8b\u4f53;\">\u8868\u793a\u6b63\u5728\u7b49\u5f85\u5904\u7406\u7684\u8bf7\u6c42\u6570\uff1b<\/span><span style=\"font-family:'Times New Roman';\">ESTABLISHED<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8868\u793a\u6b63\u5e38\u6570\u636e\u4f20\u8f93\u72b6\u6001\uff1b<\/span><span style=\"font-family:'Times New Roman';\">TIME_WAIT<\/span><span style=\"font-family:\u5b8b\u4f53;\">\u8868\u793a\u5904\u7406\u5b8c\u6bd5\uff0c\u7b49\u5f85\u8d85\u65f6\u7ed3\u675f\u7684\u8bf7\u6c42\u6570\u3002<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">\u72b6\u6001\uff1a\u63cf\u8ff0<\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">CLOSED<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u65e0\u8fde\u63a5\u662f\u6d3b\u52a8\u7684\u6216\u6b63\u5728\u8fdb\u884c<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">LISTEN<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u670d\u52a1\u5668\u5728\u7b49\u5f85\u8fdb\u5165\u547c\u53eb<\/span><\/span><\/p>\n<p class=\"p0\" style=\"margin-bottom:0pt;margin-top:0pt;\"><span style=\"font-size:10.5pt;font-family:'\u5b8b\u4f53';mso-spacerun:'yes';\">SYN_RECV<span style=\"font-family:\u5b8b\u4f53;\">\uff1a\u4e00\u4e2a...<\/span><\/span><\/p>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/326\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[287],"tags":[134,135],"class_list":["post-326","post","type-post","status-publish","format-standard","hentry","category-linux","tag-net","tag-status"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=326"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/326\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}