{"id":335,"date":"2016-01-28T02:27:10","date_gmt":"2016-01-27T23:27:10","guid":{"rendered":"http:\/\/leodev.ru\/blog\/?p=335"},"modified":"2016-01-28T02:40:14","modified_gmt":"2016-01-27T23:40:14","slug":"%d0%bf%d0%be%d0%ba%d0%b0%d0%b7%d0%b0%d1%82%d1%8c-%d0%b2%d1%81%d0%b5-%d0%be%d1%82%d0%ba%d1%80%d1%8b%d1%82%d1%8b%d0%b5-%d0%bf%d0%be%d1%80%d1%82%d1%8b-netstat","status":"publish","type":"post","link":"https:\/\/leodev.ru\/blog\/linux\/%d0%bf%d0%be%d0%ba%d0%b0%d0%b7%d0%b0%d1%82%d1%8c-%d0%b2%d1%81%d0%b5-%d0%be%d1%82%d0%ba%d1%80%d1%8b%d1%82%d1%8b%d0%b5-%d0%bf%d0%be%d1%80%d1%82%d1%8b-netstat\/","title":{"rendered":"\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0435 \u043f\u043e\u0440\u0442\u044b (netstat)"},"content":{"rendered":"<p>\u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u00a0<a href=\"http:\/\/leodev.ru\/blog\/computer-tips\/application-servers\/jboss-7-caused-by-java-net-bindexception-address-already-in-use-bind\/\" target=\"_blank\">jboss 7 \u00abCaused by: java.net.BindException: Address already in use: bind\u00bb<\/a> \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435\u00a0\u043d\u0435 \u043b\u0438\u0448\u043d\u0435\u0439.<\/p>\n<h1><b class=\"lb\">netstat<\/b><\/h1>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 <strong>netstat<\/strong> \u0443\u043c\u0435\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435\/\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435), \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u0438 \u0442.\u0434.<!--more--><\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u043e\u0440\u0442\u043e\u0432 (TCP)<br \/>\n<code><span class=\"title\">netstat<\/span> -at<\/code><\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u043f\u043e\u0440\u0442\u043e\u0432 (UDP)<br \/>\n<code><span class=\"title\">netstat<\/span> -au<\/code><\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u043f\u043e\u0440\u0442\u043e\u0432 (TCP)<br \/>\n<code>netstat <span class=\"operator\">-lt<\/span><\/code><\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u0432\u0441\u0435\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u043f\u043e\u0440\u0442\u0430\u043c<br \/>\n<code>netstat <span class=\"operator\">-s<\/span><\/code><\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u043f\u043e\u0440\u0442\u0430\u043c\u0438 &#8212; \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d PID \u0438 \u0438\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432<br \/>\n<code><span class=\"title\">netstat<\/span> -p<\/code><\/p>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043c \u0432\u0441\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432 \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 TCP\/UDP \u043f\u043e\u0440\u0442\u043e\u0432 \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 (\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f root-\u0434\u043e\u0441\u0442\u0443\u043f)<br \/>\n<code><span class=\"title\">netstat<\/span> -ltupn<\/code><\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0445 \u0445\u043e\u0441\u0442\u043e\u0432<br \/>\n<code><span class=\"title\">netstat<\/span> -lantp | grep ESTABLISHED |awk <span class=\"string\">'{print <span class=\"variable\">$5<\/span>}'<\/span> | awk -F: <span class=\"string\">'{print <span class=\"variable\">$1<\/span>}'<\/span> | sort -u<br \/>\n<\/code><\/p>\n<h1><b class=\"lb\">ss<\/b><\/h1>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 <strong>ss<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0441\u043e\u043a\u0435\u0442\u0430\u0445 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0435. \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0441\u0445\u043e\u0436\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u043a <strong>netstat<\/strong>, \u043d\u043e \u0435\u0441\u0442\u044c \u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043f\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u043c \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u0440\u0442\u043e\u043c.<\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442<br \/>\n<code><span class=\"title\">ss<\/span> -p<\/code><\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043a\u0435\u0442\u043e\u0432 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u043e\u0441\u043b\u0443\u0448\u0438\u0432\u0430\u043d\u0438\u044f<br \/>\n<code>ss <span class=\"operator\">-l<\/span><\/code><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 &#8212; \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043a \u043f\u043e\u0440\u0442\u0443 80<br \/>\n<code>ss -o <span class=\"keyword\">state<\/span> established <span class=\"string\">'( dport = :www or sport = :www )'<\/span><\/code><\/p>\n<h1><b class=\"lb\">lsof<\/b><\/h1>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 <a href=\"http:\/\/handynotes.ru\/2010\/01\/unix-utility-lsof.html\">lsof<\/a> \u0443\u043c\u0435\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0444\u0430\u0439\u043b\u043e\u043c \u0438\u043b\u0438 \u0441\u043e\u043a\u0435\u0442\u043e\u043c.<\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u0441\u0435\u0442\u0435\u0432\u044b\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439<br \/>\n<code><span class=\"title\">lsof<\/span> -i<\/code><\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 \u043f\u043e\u0440\u0442\u043e\u043c 80<br \/>\n<code><span class=\"tag\">lsof<\/span> <span class=\"tag\">-i<\/span> <span class=\"pseudo\">:80<\/span><\/code><\/p>\n<h1><b class=\"lb\">netcat<\/b><\/h1>\n<p>\u0423\u0442\u0438\u043b\u0438\u0442\u0430 <strong>netcat<\/strong> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c\/\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 TCP\/UDP \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0432\u044b\u0437\u043e\u0432\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u044b<br \/>\n<code><span class=\"title\">nc<\/span> host port<\/code><\/p>\n<p>\u041e\u0442\u043a\u0440\u043e\u0435\u043c \u043f\u0440\u0438\u0435\u043c (\u043a\u043b\u044e\u0447 <em>-l<\/em>) \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043f\u043e\u0440\u0442\u0435 1234 \u0441 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 (\u043a\u043b\u044e\u0447 <em>-v<\/em>) \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0440\u044b\u0432\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (\u043a\u043b\u044e\u0447 <em>-k<\/em>), \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <em>nc<\/em> \u0440\u0430\u0437\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u043e\u043d\u0435\u043a\u0442\u0430.<br \/>\n<code><span class=\"title\">nc<\/span> -lvk <span class=\"number\">1234<\/span><\/code><\/p>\n<p>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c\u0443 \u043f\u043e\u0440\u0442\u0443 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c <em>import antigravity<\/em> \ud83d\ude09<br \/>\n<code><span class=\"title\">nc<\/span> <span class=\"number\">127.0.0.1<\/span> <span class=\"number\">1234<\/span><br \/>\nimport antigravity<\/code><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <em>nc<\/em> &#8212; \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0444\u0430\u0439\u043b\u0430. \u041d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435<br \/>\n<code>nc <span class=\"operator\">-l<\/span> <span class=\"number\">1234<\/span> &gt; file<\/code><\/p>\n<p>\u041d\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435<br \/>\n<code><span class=\"title\">nc<\/span> localhost <span class=\"number\">1234<\/span> &lt; file<\/code><\/p>\n<p>\u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u043b\u044e\u0431\u043e\u043c\u0443 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0435\u043c\u0443\u0441\u044f. \u041d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435<br \/>\n<code>nc <span class=\"operator\">-l<\/span> <span class=\"number\">1234<\/span> &lt; file<\/code><\/p>\n<p>\u041d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0435\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u0435<br \/>\n<code><span class=\"title\">nc<\/span> localhost <span class=\"number\">1234<\/span> &gt; file<\/code><\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f shell&#8217;\u0430 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0435 (<a href=\"http:\/\/h.ackack.net\/cheat-sheets\/netcat\">\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>). \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435, \u0433\u0434\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0448\u0435\u043b<br \/>\nmkfifo \/tmp\/<span class=\"keyword\">pipe<\/span>;<br \/>\n<code>sh \/tmp\/<span class=\"keyword\">pipe<\/span> | nc -l <span class=\"number\">1234<\/span> &gt; <span class=\"regexp\">\/tmp\/pipe<\/span><\/code><\/p>\n<p>\u0415\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 <em>netcat<\/em> &#8212; \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u0441 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0442\u044c<br \/>\n<code><span class=\"title\">watch<\/span> w | nc localhost <span class=\"number\">1234<\/span><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0412\u0441\u043f\u043e\u043c\u0438\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u00a0jboss 7 \u00abCaused by: java.net.BindException: Address already in use: bind\u00bb \u0437\u0430\u043c\u0435\u0442\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u043e\u043b\u043d\u0435\u00a0\u043d\u0435 \u043b\u0438\u0448\u043d\u0435\u0439. netstat \u041a\u043e\u043c\u0430\u043d\u0434\u0430 netstat \u0443\u043c\u0435\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f (\u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435\/\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435), \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0438, \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0441\u0435\u0442\u0435\u0432\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c \u0438 \u0442.\u0434.<\/p>\n","protected":false},"author":1,"featured_media":336,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[107,112],"tags":[115,116,113,114],"class_list":["post-335","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-windows","tag-lsof","tag-netcat","tag-netstat","tag-ss"],"_links":{"self":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts\/335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/comments?post=335"}],"version-history":[{"count":4,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts\/335\/revisions"}],"predecessor-version":[{"id":341,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/posts\/335\/revisions\/341"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/media\/336"}],"wp:attachment":[{"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/media?parent=335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/categories?post=335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leodev.ru\/blog\/wp-json\/wp\/v2\/tags?post=335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}