![lsof 명령을 사용하여 localhost를 무시하고 TCP 설정 연결을 나열하는 방법은 무엇입니까?](https://linux55.com/image/227419/lsof%20%EB%AA%85%EB%A0%B9%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20localhost%EB%A5%BC%20%EB%AC%B4%EC%8B%9C%ED%95%98%EA%B3%A0%20TCP%20%EC%84%A4%EC%A0%95%20%EC%97%B0%EA%B2%B0%EC%9D%84%20%EB%82%98%EC%97%B4%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
명령을 사용하여 상태에 대한 연결을 lsof
인쇄하고 싶지만 localhost에 대한 연결은 무시합니다.TCP
ESTABLISHED
나는 시도했다:
lsof -itcp@^127.0.0.1 -stcp:established
lsof -itcp@(^127.0.0.1) -stcp:established
lsof -itcp -i ^@127.0.0.1 -stcp:established
다른 것과 비슷하지만 항상 구문 오류 응답을 받습니다.
올바른 구문은 무엇입니까?
답변1
에서 네트워크 주소를 부정할 수 없는 것 같습니다 lsof
.
lsfd
Linux에서는 다음 을 대신 사용할 수 있습니다 util-linux
.
lsfd -Q '(type =~ "^TCP") and
(name =~ "state=established") and
(name !~ "addr=(\[::1\]|127)")'
또는 @AB가 ss
언급했듯이 iproute2
:
ss -tp state established not dst 127.0/8 not dst '[::1]'