linuxÉó²é°ëÅþÁ¬ÊÇÄĸöÀú³Ì
ÔÚ linux ÖУ¬Éó²é°ëÅþÁ¬¶ÔÓ¦µÄÀú³ÌµÄÒªÁìÈçÏ£ºÊ¹Óà netstat ÏÂÁîÕÒ³ö°ëÅþÁ¬µÄ¶Ë¿Ú¡£Ê¹Óà lsof ÏÂÁîÁгöʹÓøö˿ڵÄÀú³Ì¡£
Linux ÖÐÉó²é°ëÅþÁ¬¶ÔÓ¦µÄÀú³Ì
ÔÚ Linux ϵͳÖУ¬°ëÅþÁ¬£¨HALF-CONN£©×´Ì¬ÌåÏÖ¿Í»§¶ËÒÑ·¢ËÍ SYN ÇëÇ󣬵«ÉÐδÊÕµ½Ð§ÀÍÆ÷µÄ SYN-ACK ÏìÓ¦¡£ÒªÉó²éÓë°ëÅþÁ¬¹ØÁªµÄÀú³Ì£¬¿ÉÒÔʹÓÃÒÔÏ°취£º
1. Éó²é°ëÅþÁ¬µÄ¶Ë¿Ú
ʹÓà netstat ÏÂÁîÁгöËùÓÐÍøÂçÅþÁ¬£¬²¢¹ýÂËÀ´ÓÉÓÚ°ëÅþÁ¬×´Ì¬µÄÅþÁ¬£º
netstat -an | grep "ESTAB"
µÇ¼ºó¸´ÖÆ
ʾÀýÊä³ö£º
tcp 0 0 127.0.0.1:22 127.0.0.1:53230 ESTABLISHED tcp 0 0 127.0.0.1:53230 127.0.0.1:22 ESTABLISHED tcp 0 0 ::1:53230 ::1:22 ESTABLISHED tcp 0 0 ::1:22 ::1:53230 ESTABLISHED
µÇ¼ºó¸´ÖÆ
2. ʹÓà lsof ²éÕÒÀú³Ì
ʹÓà lsof ÏÂÁîÁгöʹÓÃÌض¨¶Ë¿ÚµÄÀú³Ì£º
lsof -i :<port></port>
µÇ¼ºó¸´ÖÆ
ÆäÖÐ ÊÇ´Ó°ì·¨ 1 ÖлñµÃµÄ°ëÅþÁ¬¶Ë¿ÚºÅ¡£
ʾÀýÊä³ö£º
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 629 root 4u IPv6 3850116765 0t0 TCP *:22 (LISTEN) sshd 629 root 4u IPv4 3854596615 0t0 TCP *:22 (LISTEN) sshd 717 root 12u IPv4 3849900729 0t0 TCP 127.0.0.1:53230->127.0.0.1:22 (ESTABLISHED) sshd 733 root 11u IPv4 3849900738 0t0 TCP 127.0.0.1:22->127.0.0.1:53230 (ESTABLISHED) sshd 749 root 10u IPv6 3850116766 0t0 TCP ::1:22->::1:53230 (ESTABLISHED) sshd 765 root 9u IPv6 3850116767 0t0 TCP ::1:53230->::1:22 (ESTABLISHED)
µÇ¼ºó¸´ÖÆ
ÔÚʾÀýÊä³öÖУ¬¿ÉÒÔÕÒµ½Óë°ëÅþÁ¬¶Ë¿Ú¹ØÁªµÄÀú³ÌµÄ PID£¬ÔÚÕâÖÖÇéÐÎÏÂÊÇ PID Ϊ 717 µÄ sshd Àú³Ì¡£
ÒÔÉϾÍÊÇlinuxÉó²é°ëÅþÁ¬ÊÇÄĸöÀú³ÌµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡