답변:
iptables를 사용하여 할 수 있습니다
iptables -I INPUT -p tcp -m tcp --dport 5901 -m state --state NEW -j LOG --log-level 1 --log-prefix "New Connection "
포트 5901의 새로운 TCP 연결을 다음 /var/log/syslog
과 /var/log/kernel.log
같이 기록합니다.
12 월 12 일 07:52:48 u-10-04 커널 : [591690.935432] 새 연결 IN = eth0 OUT = MAC = 00 : 0c : 29 : 2e : 78 : f1 : 00 : 0c : 29 : eb : 43 : 22 : 08:00 SRC = 192.168.254.181 DST = 192.168.254.196 LEN = 60 TOS = 0x10 PREC = 0x00 TTL = 64 ID = 40815 DF PROTO = TCP SPT = 36972 DPT = 5901 창 = 14600 RES = 0x00 SYN URGP = 0
netstat
-v, -n, -t, -a 옵션과 함께 사용할 수 있습니다
예 :
netstat -anp | :8080 | grep ESTABLISHED | wc -l
OR
root@user:/home# netstat -vatn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.1.174:8080 192.168.1.126:53021 ESTABLISHED
tcp 0 0 192.168.1.174:8080 192.168.1.126:32950 ESTABLISHED
tcp 0 0 192.168.1.174:8080 192.168.1.126:39634 ESTABLISHED
tcp 0 0 192.168.1.174:8080 192.168.1.126:59300 ESTABLISHED
tcp 0 0 192.168.1.174:8080 192.168.1.188:49551 ESTABLISHED
tcp 0 0 192.168.1.174:9090 192.168.1.126:37865 ESTABLISHED
tcp 0 0 192.168.1.174:9090 192.168.1.188:51411 ESTABLISHED
tcp 0 0 192.168.1.174:8080 192.168.1.126:50824 ESTABLISHED