Lsof

如何解釋 lsof 結果的 name 列下的埠映射字元串?

  • November 22, 2019

我有以下輸出lsof -i:portnumber

[ztao@MongoDB ~]$ lsof -i:6379
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
redis-ser 5341 ztao    4u  IPv6  23457      0t0  TCP *:6379 (LISTEN)
redis-ser 5341 ztao    5u  IPv4  23459      0t0  TCP *:6379 (LISTEN)
redis-ser 5341 ztao    6u  IPv4  23533      0t0  TCP localhost:6379->localhost:6633 (ESTABLISHED)
redis-ser 5341 ztao    7u  IPv4  23535      0t0  TCP localhost:6379->localhost:6634 (ESTABLISHED)
redis-ser 5341 ztao    8u  IPv4  23538      0t0  TCP localhost:6379->localhost:6635 (ESTABLISHED)
redis-ser 5341 ztao    9u  IPv4  23540      0t0  TCP localhost:6379->localhost:6636 (ESTABLISHED)
redis-ser 5341 ztao   10u  IPv4  23839      0t0  TCP localhost:6379->localhost:6747 (ESTABLISHED)
redis-ser 5341 ztao   11u  IPv4  23842      0t0  TCP localhost:6379->localhost:6748 (ESTABLISHED)
newsProvi 5349 ztao    6u  IPv4  23530      0t0  TCP localhost:6633->localhost:6379 (ESTABLISHED)
newsProvi 5349 ztao    7u  IPv4  23532      0t0  TCP localhost:6634->localhost:6379 (ESTABLISHED)
newsProvi 5349 ztao    8u  IPv4  23536      0t0  TCP localhost:6635->localhost:6379 (ESTABLISHED)
newsProvi 5349 ztao    9u  IPv4  23539      0t0  TCP localhost:6636->localhost:6379 (ESTABLISHED)
newsDistr 5456 ztao   12u  IPv4  23838      0t0  TCP localhost:6747->localhost:6379 (ESTABLISHED)
newsDistr 5456 ztao   13u  IPv4  23841      0t0  TCP localhost:6748->localhost:6379 (ESTABLISHED)

我很難理解是什麼 localhost:6379->localhost:6633 (ESTABLISHED)意思。我試圖搜尋但找不到答案。這一定是一些非常基礎的知識,但我是新手,我不知道。有什麼幫助嗎?

localhost:6379->localhost:6633 (ESTABLISHED)表示在localhost的埠 6379 和 6633 之間建立了連接。(“已建立”是TCP/IP 狀態機中的一個狀態;其他協議也有類似的狀態。)

箭頭不代表通信的方向;它反映了港口的所有權。箭頭左側是屬於列出的程序(Redis)的埠,箭頭右側是屬於連接遠端端的埠。

由於連接的兩端都是本地的,所以可以看到連接的另一端:

newsProvi 5349 ztao    6u  IPv4  23530      0t0  TCP localhost:6633->localhost:6379 (ESTABLISHED)

引用自:https://unix.stackexchange.com/questions/553540