184.13.80.102 - - [07/Jan/2019:00:33:10 -0500] "GET /?p=454 HTTP/1.1" 200 8822 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [07/Jan/2019:20:16:12 -0500] "GET /?p=454 HTTP/1.1" 200 8820 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0"
184.13.80.102 - - [07/Jan/2019:23:14:10 -0500] "GET /?p=454 HTTP/1.1" 200 8820 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [08/Jan/2019:02:32:22 -0500] "GET /?p=454 HTTP/1.1" 200 8819 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [08/Jan/2019:03:57:19 -0500] "GET /?p=454 HTTP/1.1" 200 8819 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [08/Jan/2019:23:05:32 -0500] "GET /?p=454 HTTP/1.1" 200 8819 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [09/Jan/2019:07:35:10 -0500] "GET /?p=454 HTTP/1.1" 200 8821 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [09/Jan/2019:14:45:36 -0500] "GET /?p=454 HTTP/1.1" 200 8819 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [09/Jan/2019:23:22:03 -0500] "GET /?p=454 HTTP/1.1" 200 8821 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [10/Jan/2019:23:50:28 -0500] "GET /?p=454 HTTP/1.1" 200 8819 "-" "Mozilla/5.0 (X11; Linux i686; rv:60.0) Gecko/20100101 Firefox/60.0"
184.13.80.102 - - [13/Jan/2019:00:56:36 -0500] "GET /?p=454 HTTP/1.1" 200 8821 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [15/Jan/2019:20:47:56 -0500] "GET /?p=454 HTTP/1.1" 200 8819 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0"
184.13.80.102 - - [15/Jan/2019:22:36:09 -0500] "GET /?p=454 HTTP/1.1" 200 8821 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0"
이 사용자가 내 서버를 가득 채우려고 합니다. 특정 항목을 사용 cat
하거나 awk
확인 하고 access_log
서버에 액세스하려는 ip
일수를 어떻게 감지할 수 있습니까 ?ip
이 경우 6일이 됩니다.
답변1
다음 명령을 사용할 수 있습니다.
grep "$ip" log_file | cut -d '[' -f2 | cut -d '/' -f1 | uniq | wc -l
ip address
검색 중인 내용이 변수에 있고 ip
그것이 log_file
로그 파일이라고 가정해 보겠습니다 .
ip
변수를 다음과 같이 정의 할 수 있습니다 ip="184.13.80.102"
.
답변2
#!/bin/bash
echo "enter the ip"
read ip
awk -v i="$i" '/i/{print $4}' filename| sed "s/\[//g"| awk '{print substr($1,1,2)}'|awk '{if (!seen[$1]++)print $1}'| wc -l| sed "1i Below are Number of times "$ip" exsists"
output
Below are Number of times 184.13.80.102 exsists
6