Nginx Log Top IP

Today access.log

    361 66.249.73.197
    352 66.249.73.198
    311 20.171.207.105
    242 66.249.73.199
    219 106.117.100.99
    131 111.33.88.87
    124 121.10.198.7
    110 216.244.66.241
    110 120.229.48.3
    105 172.233.75.10
    104 122.227.36.90
    100 171.105.200.193
     98 27.27.238.12
     96 117.61.111.206
     92 119.131.216.242
     91 223.104.195.95
     85 119.129.50.126
     81 111.58.226.68
     80 117.90.107.230
     75 223.104.114.198

Yesterday access.log.1

   2696 43.153.110.86
    558 66.249.79.6
    519 66.249.79.7
    356 216.244.66.241
    353 66.249.79.8
    300 188.165.241.181
    249 217.182.175.163
    218 81.71.5.172
    185 120.229.48.3
    180 106.117.76.81
    176 121.10.198.7
    154 123.182.226.103
    151 217.182.195.225
    148 222.212.192.0
    134 172.233.75.10
    131 119.129.50.126
    130 111.33.88.87
    116 223.99.125.94
    106 27.185.72.194
    106 112.122.28.84

Introduction

Statistics for Nginx based on the access.log file: Count the number of unique IP addresses. Determine whether each IP is allowed or denied based on the request, and provide details on any blocked IPs.

Command

$ awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -n 20