この記事は最終更新日から1年以上が経過しています。
@TanakaSoftwareLab
投稿日 2019/6/6
更新日 2019/7/16 ✏
nginxで遮断IPアドレス一覧を外部ファイルで管理する
特定のIPアドレスからのアクセスを nginx で遮断する方法です。
規制対象IPアドレスの一覧表は外部ファイルとして管理し、メンテナンスしやすくします。IPアドレス一覧表以外に編集するファイルは nginx.conf だけです。編集すると言っても、たった一行追加するだけです。
せっかくなので、私が管理するWebサーバへ総当り攻撃を仕掛けてくるアタッカーのIPアドレス一覧 (IPアドレス規制ファイル) も下記に載せておきます。ご自由にコピーしてお使いください。
目次
設定
IPアドレス規制ファイル (随時更新)
IPアドレス規制ファイル/etc/nginx/nginx-ip-restrictions.conf
(名前は何でも良い) を作成:
# 主に中国と韓国からの定番のアタッカーIPアドレスを遮断
#
deny 1.24.0.0/13;
deny 1.48.0.0/15;
deny 1.50.0.0/16;
deny 1.56.0.0/13;
deny 1.68.0.0/14;
deny 1.80.0.0/13;
deny 1.92.0.0/14;
deny 1.180.0.0/14;
deny 1.188.0.0/14;
deny 1.192.0.0/13;
deny 1.202.0.0/15;
deny 1.204.0.0/14;
deny 14.16.0.0/12;
deny 14.104.0.0/13;
deny 14.112.0.0/12;
deny 14.134.0.0/15;
deny 14.144.0.0/12;
deny 14.204.0.0/15;
deny 14.208.0.0/12;
deny 23.80.54.0/24;
deny 23.104.141.0/24;
deny 23.105.14.0/24;
deny 23.226.208.0/24;
deny 27.8.0.0/13;
deny 27.16.0.0/12;
deny 27.36.0.0/14;
deny 27.40.0.0/13;
deny 27.50.128.0/17;
deny 27.54.192.0/18;
deny 27.106.128.0/18;
deny 27.115.0.0/17;
deny 27.148.0.0/14;
deny 27.152.0.0/13;
deny 27.184.0.0/13;
deny 27.192.0.0/11;
deny 27.224.0.0/14;
deny 36.1.0.0/16;
deny 36.4.0.0/14;
deny 36.26.0.0/16;
deny 36.32.0.0/14;
deny 36.36.0.0/16;
deny 36.40.0.0/13;
deny 36.48.0.0/15;
deny 36.56.0.0/13;
deny 36.96.0.0/11;
deny 36.128.0.0/11;
deny 36.248.0.0/14;
deny 39.64.0.0/11;
deny 39.96.0.0/13;
deny 39.128.0.0/10;
deny 42.4.0.0/14;
deny 42.48.0.0/15;
deny 42.52.0.0/14;
deny 42.56.0.0/14;
deny 42.84.0.0/14;
deny 42.88.0.0/13;
deny 42.96.128.0/17;
deny 42.100.0.0/14;
deny 42.120.0.0/14;
deny 42.156.0.0/16;
deny 42.176.0.0/13;
deny 42.185.0.0/16;
deny 42.202.0.0/15;
deny 42.224.0.0/12;
deny 42.242.0.0/15;
deny 42.248.0.0/15;
deny 43.255.0.0/20;
deny 43.255.16.0/22;
deny 43.255.48.0/22;
deny 43.255.60.0/22;
deny 43.255.64.0/20;
deny 43.255.96.0/20;
deny 43.255.144.0/22;
deny 43.255.168.0/22;
deny 43.255.176.0/22;
deny 43.255.184.0/22;
deny 43.255.192.0/22;
deny 43.255.200.0/21;
deny 43.255.208.0/21;
deny 43.255.224.0/21;
deny 43.255.232.0/22;
deny 43.255.244.0/22;
deny 47.88.0.0/14;
deny 47.88.0.0/14;
deny 47.92.0.0/14;
deny 47.100.0.0/14;
deny 49.5.0.0/16;
deny 49.64.0.0/11;
deny 49.112.0.0/13;
deny 54.222.0.0/15;
deny 58.16.0.0/14;
deny 58.20.0.0/16;
deny 58.21.0.0/16;
deny 58.22.0.0/15;
deny 58.34.0.0/16;
deny 58.37.0.0/16;
deny 58.38.0.0/16;
deny 58.40.0.0/16;
deny 58.42.0.0/16;
deny 58.44.0.0/14;
deny 58.48.0.0/13;
deny 58.56.0.0/14;
deny 58.60.0.0/14;
deny 58.68.128.0/17;
deny 58.82.0.0/15;
deny 58.100.0.0/15;
deny 58.116.0.0/14;
deny 58.128.0.0/13;
deny 58.208.0.0/12;
deny 58.240.0.0/13;
deny 58.248.0.0/13;
deny 59.32.0.0/12;
deny 59.48.0.0/14;
deny 59.52.0.0/14;
deny 59.56.0.0/13;
deny 59.72.0.0/16;
deny 59.108.0.0/15;
deny 59.172.0.0/14;
deny 60.0.0.0/12;
deny 60.11.0.0/16;
deny 60.12.0.0/14;
deny 60.16.0.0/13;
deny 60.24.0.0/13;
deny 60.160.0.0/11;
deny 60.194.0.0/15;
deny 60.205.0.0/16;
deny 60.208.0.0/12;
deny 60.253.128.0/17;
deny 61.0.32.0/20;
deny 61.4.64.0/20;
deny 61.4.80.0/22;
deny 61.4.176.0/20;
deny 61.48.0.0/13;
deny 61.128.0.0/10;
deny 61.135.0.0/16;
deny 61.136.0.0/18;
deny 61.139.0.0/16;
deny 61.145.73.208/28;
deny 61.147.0.0/16;
deny 61.150.0.0/16;
deny 61.152.0.0/16;
deny 61.154.0.0/16;
deny 61.158.0.0/16;
deny 61.160.0.0/16;
deny 61.162.0.0/15;
deny 61.164.0.0/16;
deny 61.172.0.0/15;
deny 61.175.0.0/16;
deny 61.177.0.0/16;
deny 61.179.0.0/16;
deny 61.183.0.0/16;
deny 61.184.0.0/16;
deny 61.185.219.232/29;
deny 61.187.0.0/16;
deny 61.188.0.0/16;
deny 61.219.0.0/16;
deny 61.232.0.0/14;
deny 61.236.0.0/15;
deny 61.240.0.0/14;
deny 62.234.0.0/16;
deny 94.191.0.0/17;
deny 101.16.0.0/12;
deny 101.37.0.0/16;
deny 101.64.0.0/13;
deny 101.72.0.0/14;
deny 101.76.0.0/15;
deny 101.80.0.0/12;
deny 101.132.0.0/15;
deny 101.200.0.0/15;
deny 101.224.0.0/13;
deny 101.248.0.0/15;
deny 101.254.0.0/16;
deny 103.43.16.0/22;
deny 103.107.236.0/24;
deny 103.211.164.0/22;
deny 103.253.4.0/22;
deny 106.4.0.0/14;
deny 106.8.0.0/15;
deny 106.12.0.0/14;
deny 106.16.0.0/12;
deny 106.32.0.0/12;
deny 106.43.0.0/16;
deny 106.56.0.0/13;
deny 106.74.0.0/15;
deny 106.80.0.0/12;
deny 106.108.0.0/14;
deny 106.112.0.0/13;
deny 106.120.0.0/13;
deny 110.6.0.0/15;
deny 110.16.0.0/14;
deny 110.51.0.0/16;
deny 110.52.0.0/15;
deny 110.80.0.0/13;
deny 110.88.0.0/14;
deny 110.96.0.0/11;
deny 110.152.0.0/14;
deny 110.156.0.0/15;
deny 110.166.0.0/15;
deny 110.173.0.0/19;
deny 110.173.32.0/20;
deny 110.173.64.0/18;
deny 110.176.0.0/14;
deny 110.184.0.0/13;
deny 110.192.0.0/11;
deny 110.228.0.0/14;
deny 110.240.0.0/12;
deny 111.0.0.0/10;
deny 111.72.0.0/13;
deny 111.85.0.0/16;
deny 111.112.0.0/15;
deny 111.120.0.0/14;
deny 111.124.0.0/16;
deny 111.126.0.0/15;
deny 111.128.0.0/11;
deny 111.160.0.0/13;
deny 111.172.0.0/14;
deny 111.176.0.0/13;
deny 111.192.0.0/12;
deny 111.224.0.0/14;
deny 111.228.0.0/14;
deny 111.230.0.0/15;
deny 112.0.0.0/10;
deny 112.64.0.0/14;
deny 112.73.0.0/16;
deny 112.74.0.0/16;
deny 112.80.0.0/12;
deny 112.98.0.0/15;
deny 112.100.0.0/14;
deny 112.109.128.0/17;
deny 112.111.0.0/16;
deny 112.112.0.0/14;
deny 112.116.0.0/15;
deny 112.122.0.0/15;
deny 112.192.0.0/14;
deny 112.224.0.0/11;
deny 113.0.0.0/13;
deny 113.8.0.0/15;
deny 113.12.0.0/14;
deny 113.16.0.0/15;
deny 113.18.0.0/16;
deny 113.54.0.0/15;
deny 113.56.0.0/15;
deny 113.58.0.0/16;
deny 113.59.0.0/17;
deny 113.62.0.0/15;
deny 113.64.0.0/10;
deny 113.120.0.0/13;
deny 113.128.0.0/15;
deny 113.132.0.0/14;
deny 113.136.0.0/13;
deny 113.194.0.0/15;
deny 113.200.0.0/15;
deny 113.204.0.0/14;
deny 113.218.0.0/15;
deny 113.220.0.0/14;
deny 113.224.0.0/12;
deny 113.240.0.0/13;
deny 113.248.0.0/14;
deny 114.28.0.0/16;
deny 114.54.0.0/15;
deny 114.64.0.0/14;
deny 114.80.0.0/12;
deny 114.96.0.0/13;
deny 114.104.0.0/14;
deny 114.112.0.0/14;
deny 114.135.0.0/16;
deny 114.138.0.0/15;
deny 114.215.0.0/16;
deny 114.216.0.0/13;
deny 114.224.0.0/11;
deny 115.24.0.0/15;
deny 115.28.0.0/15;
deny 115.32.0.0/14;
deny 115.48.0.0/12;
deny 115.84.0.0/18;
deny 115.100.0.0/15;
deny 115.148.0.0/14;
deny 115.152.0.0/15;
deny 115.159.0.0/16;
deny 115.166.64.0/19;
deny 115.168.0.0/14;
deny 115.192.0.0/11;
deny 115.224.0.0/12;
deny 116.1.0.0/16;
deny 116.2.0.0/15;
deny 116.4.0.0/14;
deny 116.8.0.0/14;
deny 116.16.0.0/12;
deny 116.52.0.0/14;
deny 116.56.0.0/15;
deny 116.60.0.0/14;
deny 116.76.0.0/15;
deny 116.85.0.0/16;
deny 116.90.80.0/20;
deny 116.95.0.0/16;
deny 116.112.0.0/14;
deny 116.116.0.0/15;
deny 116.128.0.0/10;
deny 116.204.0.0/15;
deny 116.207.0.0/16;
deny 116.208.0.0/14;
deny 116.213.64.0/18;
deny 116.213.128.0/17;
deny 116.224.0.0/12;
deny 116.248.0.0/15;
deny 116.252.0.0/15;
deny 116.254.128.0/18;
deny 117.8.0.0/13;
deny 117.21.0.0/16;
deny 117.22.0.0/15;
deny 117.24.0.0/13;
deny 117.32.0.0/13;
deny 117.40.0.0/14;
deny 117.44.0.0/15;
deny 117.50.0.0/16;
deny 117.51.0.0/16;
deny 117.57.0.0/16;
deny 117.60.0.0/14;
deny 117.64.0.0/13;
deny 117.79.224.0/20;
deny 117.80.0.0/12;
deny 117.106.0.0/15;
deny 117.112.0.0/13;
deny 117.128.0.0/10;
deny 118.24.0.0/15;
deny 118.26.0.0/16;
deny 118.72.0.0/13;
deny 118.80.0.0/15;
deny 118.89.0.0/16;
deny 118.112.0.0/13;
deny 118.120.0.0/14;
deny 118.124.0.0/15;
deny 118.132.0.0/14;
deny 118.144.0.0/14;
deny 118.180.0.0/14;
deny 118.186.0.0/15;
deny 118.192.0.0/15;
deny 118.194.0.0/16;
deny 118.213.0.0/16;
deny 118.244.0.0/16;
deny 118.248.0.0/13;
deny 119.0.0.0/13;
deny 119.8.0.0/16;
deny 119.10.0.0/16;
deny 119.18.192.0/20;
deny 119.23.0.0/16;
deny 119.28.0.0/15;
deny 119.32.0.0/14;
deny 119.36.0.0/16;
deny 119.39.0.0/16;
deny 119.44.0.0/16;
deny 119.48.0.0/13;
deny 119.57.0.0/16;
deny 119.60.0.0/15;
deny 119.62.0.0/16;
deny 119.84.0.0/14;
deny 119.88.0.0/14;
deny 119.96.0.0/13;
deny 119.108.0.0/15;
deny 119.112.0.0/13;
deny 119.120.0.0/13;
deny 119.128.0.0/12;
deny 119.144.0.0/14;
deny 119.162.0.0/15;
deny 119.164.0.0/14;
deny 119.176.0.0/12;
deny 119.233.0.0/16;
deny 119.248.0.0/14;
deny 120.0.0.0/12;
deny 120.24.0.0/14;
deny 120.30.0.0/15;
deny 120.32.0.0/13;
deny 120.40.0.0/14;
deny 120.68.0.0/14;
deny 120.76.0.0/14;
deny 120.80.0.0/13;
deny 120.92.0.0/16;
deny 120.192.0.0/10;
deny 121.0.16.0/20;
deny 121.4.0.0/15;
deny 121.8.0.0/13;
deny 121.16.0.0/12;
deny 121.32.0.0/14;
deny 121.40.0.0/14;
deny 121.52.208.0/20;
deny 121.52.224.0/19;
deny 121.56.0.0/15;
deny 121.60.0.0/14;
deny 121.68.0.0/14;
deny 121.76.0.0/15;
deny 121.100.128.0/17;
deny 121.196.0.0/14;
deny 121.201.0.0/16;
deny 121.204.0.0/14;
deny 121.224.0.0/12;
deny 122.4.0.0/14;
deny 122.8.0.0/16;
deny 122.10.128.0/17;
deny 122.51.128.0/17;
deny 122.64.0.0/11;
deny 122.96.0.0/15;
deny 122.114.0.0/16;
deny 122.119.0.0/16;
deny 122.136.0.0/13;
deny 122.156.0.0/14;
deny 122.188.0.0/14;
deny 122.192.0.0/14;
deny 122.198.0.0/16;
deny 122.200.64.0/18;
deny 122.224.0.0/12;
deny 122.240.0.0/13;
deny 123.4.0.0/14;
deny 123.8.0.0/13;
deny 123.52.0.0/14;
deny 123.56.0.0/14;
deny 123.64.0.0/11;
deny 123.97.128.0/17;
deny 123.100.0.0/19;
deny 123.112.0.0/12;
deny 123.128.0.0/13;
deny 123.138.0.0/15;
deny 123.144.0.0/14;
deny 123.148.0.0/15;
deny 123.150.0.0/15;
deny 123.152.0.0/13;
deny 123.160.0.0/14;
deny 123.164.0.0/14;
deny 123.172.0.0/15;
deny 123.178.0.0/15;
deny 123.180.0.0/14;
deny 123.184.0.0/13;
deny 123.196.0.0/15;
deny 123.206.0.0/15;
deny 123.207.0.0/16;
deny 123.232.0.0/14;
deny 123.244.0.0/14;
deny 123.249.0.0/16;
deny 124.42.0.0/16;
deny 124.64.0.0/15;
deny 124.66.0.0/17;
deny 124.67.0.0/16;
deny 124.72.0.0/13;
deny 124.88.0.0/15;
deny 124.92.0.0/14;
deny 124.112.0.0/15;
deny 124.114.0.0/15;
deny 124.117.0.0/16;
deny 124.118.0.0/15;
deny 124.126.0.0/15;
deny 124.128.0.0/13;
deny 124.152.0.0/16;
deny 124.160.0.0/13;
deny 124.192.0.0/15;
deny 124.200.0.0/13;
deny 124.224.0.0/16;
deny 124.226.0.0/15;
deny 124.228.0.0/14;
deny 124.234.0.0/15;
deny 124.236.0.0/14;
deny 124.240.0.0/17;
deny 124.240.128.0/18;
deny 124.248.0.0/17;
deny 125.32.0.0/14;
deny 125.36.0.0/14;
deny 125.40.0.0/13;
deny 125.64.0.0/12;
deny 125.79.0.0/16;
deny 125.80.0.0/13;
deny 125.88.0.0/13;
deny 125.104.0.0/13;
deny 125.112.0.0/12;
deny 125.210.0.0/15;
deny 125.216.0.0/13;
deny 129.28.0.0/16;
deny 129.204.0.0/16;
deny 132.232.0.0/16;
deny 134.175.0.0/16;
deny 139.129.0.0/16;
deny 139.170.0.0/16;
deny 139.189.0.0/16;
deny 139.199.0.0/16;
deny 139.206.0.0/16;
deny 139.208.0.0/13;
deny 139.217.0.0/16;
deny 139.224.0.0/16;
deny 139.226.0.0/15;
deny 140.143.0.0/16;
deny 140.206.0.0/15;
deny 140.224.0.0/16;
deny 140.237.0.0/16;
deny 140.240.0.0/16;
deny 140.246.0.0/16;
deny 140.249.0.0/16;
deny 140.255.0.0/16;
deny 142.4.117.0/30;
deny 144.0.0.0/16;
deny 144.12.0.0/16;
deny 144.52.0.0/16;
deny 144.123.0.0/16;
deny 144.255.0.0/16;
deny 150.109.0.0/16;
deny 150.138.0.0/15;
deny 153.0.0.0/16;
deny 153.99.0.0/16;
deny 159.138.0.0/20;
deny 159.226.0.0/16;
deny 162.209.168.0/24;
deny 171.8.0.0/13;
deny 171.34.0.0/15;
deny 171.36.0.0/14;
deny 171.40.0.0/13;
deny 171.80.0.0/14;
deny 171.88.0.0/13;
deny 171.104.0.0/13;
deny 171.112.0.0/14;
deny 171.116.0.0/14;
deny 171.120.0.0/13;
deny 171.208.0.0/12;
deny 175.0.0.0/12;
deny 175.16.0.0/13;
deny 175.24.0.0/14;
deny 175.30.0.0/15;
deny 175.42.0.0/15;
deny 175.44.0.0/16;
deny 175.46.0.0/15;
deny 175.48.0.0/12;
deny 175.64.0.0/11;
deny 175.102.0.0/16;
deny 175.106.128.0/17;
deny 175.146.0.0/15;
deny 175.148.0.0/14;
deny 175.152.0.0/14;
deny 175.160.0.0/12;
deny 175.178.0.0/16;
deny 175.184.128.0/18;
deny 175.185.0.0/16;
deny 175.186.0.0/15;
deny 175.188.0.0/14;
deny 180.76.0.0/16;
deny 180.95.128.0/17;
deny 180.96.0.0/11;
deny 180.136.0.0/13;
deny 180.152.0.0/13;
deny 180.160.0.0/12;
deny 180.208.0.0/15;
deny 180.212.0.0/15;
deny 182.18.0.0/17;
deny 182.32.0.0/12;
deny 182.50.112.0/20;
deny 182.61.0.0/16;
deny 182.84.0.0/14;
deny 182.88.0.0/14;
deny 182.96.0.0/12;
deny 182.112.0.0/12;
deny 182.128.0.0/12;
deny 182.144.0.0/13;
deny 182.200.0.0/13;
deny 182.240.0.0/13;
deny 183.0.0.0/10;
deny 183.64.0.0/13;
deny 183.92.0.0/14;
deny 183.128.0.0/11;
deny 183.160.0.0/12;
deny 183.184.0.0/13;
deny 183.192.0.0/10;
deny 192.34.109.224/28;
deny 193.112.178.0/24;
deny 198.2.203.64/28;
deny 198.2.212.160/28;
deny 198.15.171.64/26;
deny 202.43.144.0/22;
deny 202.46.32.0/19;
deny 202.65.96.0/20;
deny 202.66.0.0/16;
deny 202.75.208.0/20;
deny 202.96.0.0/12;
deny 202.111.160.0/19;
deny 202.112.0.0/14;
deny 202.117.0.0/16;
deny 202.127.112.0/20;
deny 202.162.36.0/24;
deny 202.165.176.0/20;
deny 202.196.80.0/20;
deny 203.69.0.0/16;
deny 203.81.16.0/20;
deny 203.86.0.0/18;
deny 203.86.64.0/19;
deny 203.93.0.0/16;
deny 203.169.160.0/19;
deny 203.171.224.0/20;
deny 203.195.160.0/23;
deny 210.5.0.0/19;
deny 210.12.0.0/16;
deny 210.14.128.0/19;
deny 210.21.0.0/16;
deny 210.22.0.0/16;
deny 210.32.0.0/14;
deny 210.51.0.0/16;
deny 210.52.0.0/15;
deny 210.75.0.0/16;
deny 210.77.0.0/16;
deny 210.79.64.0/18;
deny 210.192.96.0/19;
deny 211.76.96.0/20;
deny 211.78.208.0/20;
deny 211.80.0.0/13;
deny 211.86.144.0/20;
deny 211.90.0.0/15;
deny 211.92.0.0/14;
deny 211.96.0.0/13;
deny 211.136.0.0/13;
deny 211.144.0.0/12;
deny 211.160.0.0/13;
deny 211.233.70.0/24;
deny 212.64.0.0/17;
deny 218.0.0.0/11;
deny 218.56.0.0/13;
deny 218.64.0.0/11;
deny 218.84.0.0/14;
deny 218.88.0.0/13;
deny 218.96.0.0/14;
deny 218.102.0.0/16;
deny 218.104.0.0/14;
deny 218.108.0.0/15;
deny 218.194.80.0/20;
deny 218.200.0.0/13;
deny 218.240.0.0/13;
deny 218.249.0.0/16;
deny 219.128.0.0/11;
deny 219.154.0.0/15;
deny 219.223.192.0/18;
deny 219.232.0.0/16;
deny 219.234.80.0/20;
deny 219.235.0.0/16;
deny 219.238.0.0/15;
deny 220.112.0.0/16;
deny 220.154.0.0/15;
deny 220.160.0.0/11;
deny 220.181.0.0/16;
deny 220.191.0.0/16;
deny 220.192.0.0/12;
deny 220.228.70.0/24;
deny 220.242.0.0/15;
deny 220.248.0.0/14;
deny 220.250.0.0/19;
deny 220.252.0.0/16;
deny 221.0.0.0/12;
deny 221.122.0.0/15;
deny 221.130.0.0/15;
deny 221.136.0.0/15;
deny 221.172.0.0/14;
deny 221.176.0.0/13;
deny 221.192.0.0/14;
deny 221.196.0.0/15;
deny 221.198.0.0/16;
deny 221.199.0.0/17;
deny 221.200.0.0/14;
deny 221.204.0.0/15;
deny 221.206.0.0/16;
deny 221.207.0.0/16;
deny 221.208.0.0/12;
deny 221.212.0.0/15;
deny 221.214.0.0/15;
deny 221.216.0.0/13;
deny 221.224.0.0/13;
deny 221.228.0.0/14;
deny 221.232.0.0/13;
deny 222.32.0.0/11;
deny 222.64.0.0/12;
deny 222.80.0.0/12;
deny 222.128.0.0/14;
deny 222.132.0.0/14;
deny 222.136.0.0/13;
deny 222.160.0.0/14;
deny 222.168.0.0/13;
deny 222.172.222.0/24;
deny 222.176.0.0/13;
deny 222.184.0.0/13;
deny 222.200.0.0/16;
deny 222.208.0.0/13;
deny 222.216.0.0/14;
deny 222.220.0.0/15;
deny 222.222.0.0/15;
deny 222.240.0.0/13;
deny 222.249.0.0/16;
deny 223.4.0.0/14;
deny 223.8.0.0/13;
deny 223.64.0.0/11;
deny 223.96.0.0/12;
deny 223.112.0.0/14;
deny 223.144.0.0/12;
deny 223.198.0.0/15;
deny 223.214.0.0/15;
deny 223.223.176.0/20;
deny 223.223.192.0/20;
deny 223.255.0.0/17;
deny 223.240.0.0/13;
deny 58.65.232.0/21;
deny 59.148.0.0/15;
deny 59.188.0.0/16;
deny 61.244.0.0/16;
deny 103.249.196.0/24;
deny 103.253.96.0/22;
deny 103.253.140.0/22;
deny 110.173.48.0/20;
deny 112.121.160.0/19;
deny 112.213.64.0/20;
deny 112.213.96.0/19;
deny 113.10.128.0/17;
deny 113.28.160.0/19;
deny 113.252.0.0/14;
deny 118.99.0.0/18;
deny 118.140.0.0/14;
deny 121.127.224.0/19;
deny 122.10.0.0/17;
deny 123.242.229.0/24;
deny 147.8.0.0/16;
deny 164.52.0.0/17;
deny 180.235.134.0/24;
deny 202.69.64.0/19;
deny 202.85.128.0/19;
deny 202.133.8.0/21;
deny 203.78.32.0/21;
deny 203.198.0.0/16;
deny 203.218.0.0/16;
deny 210.176.0.0/19;
deny 210.176.48.0/20;
deny 210.176.64.0/18;
deny 210.176.128.0/17;
deny 210.177.0.0/16;
deny 210.209.64.0/18;
deny 218.103.0.0/16;
deny 218.250.0.0/16;
deny 218.252.0.0/14;
deny 219.76.0.0/14;
deny 219.90.112.0/20;
deny 222.166.0.0/16;
deny 223.16.0.0/14;
deny 223.197.128.0/18;
deny 1.208.0.0/12;
deny 1.224.0.0/11;
deny 14.32.0.0/11;
deny 14.64.0.0/11;
deny 27.115.128.0/17;
deny 27.255.64.0/18;
deny 58.72.0.0/13;
deny 58.120.0.0/13;
deny 58.140.0.0/14;
deny 58.148.0.0/14;
deny 58.180.40.0/21;
deny 58.224.0.0/12;
deny 59.0.0.0/11;
deny 59.86.192.0/18;
deny 59.186.0.0/15;
deny 61.32.0.0/13;
deny 61.40.0.0/14;
deny 61.72.0.0/13;
deny 61.80.0.0/15;
deny 61.96.0.0/12;
deny 61.110.16.0/20;
deny 61.248.0.0/13;
deny 101.79.0.0/16;
deny 110.8.0.0/13;
deny 110.45.0.0/16;
deny 112.144.0.0/12;
deny 112.160.0.0/11;
deny 112.216.0.0/13;
deny 113.30.64.0/18;
deny 114.29.0.0/17;
deny 114.108.0.0/17;
deny 114.108.128.0/18;
deny 114.200.0.0/13;
deny 115.0.0.0/12;
deny 115.16.0.0/13;
deny 115.40.0.0/15;
deny 115.68.0.0/16;
deny 115.88.0.0/13;
deny 116.40.0.0/16;
deny 116.45.176.0/20;
deny 116.93.192.0/19;
deny 116.120.0.0/13;
deny 117.110.0.0/15;
deny 118.32.0.0/11;
deny 118.128.0.0/14;
deny 118.216.0.0/13;
deny 119.64.0.0/13;
deny 119.192.0.0/11;
deny 120.50.64.0/18;
deny 121.78.0.0/16;
deny 121.88.0.0/16;
deny 121.101.224.0/19;
deny 121.127.64.0/18;
deny 121.127.128.0/18;
deny 121.128.0.0/10;
deny 121.254.0.0/16;
deny 122.32.0.0/13;
deny 122.44.112.0/20;
deny 122.99.128.0/17;
deny 122.252.64.0/18;
deny 123.111.0.0/16;
deny 123.140.0.0/14;
deny 123.212.0.0/14;
deny 123.248.0.0/16;
deny 124.0.0.0/15;
deny 124.50.87.161;
deny 124.136.0.0/14;
deny 124.217.192.0/19;
deny 125.128.0.0/11;
deny 125.176.0.0/12;
deny 125.240.0.0/13;
deny 125.248.0.0/14;
deny 143.248.0.0/16;
deny 166.104.0.0/16;
deny 168.126.0.0/16;
deny 168.188.0.0/16;
deny 175.45.176.0/22;
deny 175.112.0.0/12;
deny 175.192.0.0/13;
deny 180.64.0.0/13;
deny 180.224.0.0/13;
deny 182.224.0.0/14;
deny 183.96.0.0/11;
deny 202.30.0.0/15;
deny 202.133.16.0/20;
deny 202.179.176.0/21;
deny 203.226.0.0/15;
deny 203.228.0.0/14;
deny 203.244.0.0/14;
deny 203.248.0.0/13;
deny 210.93.0.0/16;
deny 210.94.0.0/15;
deny 210.108.0.0/14;
deny 210.112.0.0/14;
deny 210.117.128.0/18;
deny 210.118.216.192/26;
deny 210.123.0.0/16;
deny 210.124.0.0/14;
deny 210.178.0.0/15;
deny 210.180.0.0/15;
deny 210.204.0.0/15;
deny 210.210.192.0/18;
deny 210.219.0.0/16;
deny 210.220.0.0/14;
deny 211.32.0.0/12;
deny 211.48.0.0/15;
deny 211.50.0.0/15;
deny 211.52.0.0/15;
deny 211.54.0.0/15;
deny 211.56.0.0/14;
deny 211.62.35.0/24;
deny 211.104.0.0/13;
deny 211.112.0.0/13;
deny 211.168.0.0/13;
deny 211.176.0.0/12;
deny 211.192.0.0/12;
deny 211.208.0.0/14;
deny 211.216.0.0/13;
deny 211.224.0.0/13;
deny 211.232.0.0/13;
deny 211.240.0.0/12;
deny 218.36.0.0/14;
deny 218.48.0.0/13;
deny 218.144.0.0/12;
deny 218.209.0.0/16;
deny 218.232.0.0/14;
deny 218.236.0.0/14;
deny 219.240.0.0/15;
deny 219.248.0.0/13;
deny 219.250.88.0/21;
deny 220.72.0.0/13;
deny 220.80.0.0/13;
deny 220.95.88.0/24;
deny 220.118.0.0/16;
deny 220.119.0.0/16;
deny 221.128.0.0/12;
deny 221.140.0.0/14;
deny 221.144.0.0/12;
deny 221.160.0.0/13;
deny 221.168.0.0/16;
deny 221.163.46.0/24;
deny 222.96.0.0/12;
deny 222.112.0.0/13;
deny 222.120.0.0/15;
deny 222.122.0.0/16;
deny 222.231.0.0/18;
deny 222.232.0.0/13;
deny 123.0.0.0/20;
deny 61.75.30.0/25;
deny 61.72.0.0/15;
deny 61.75.30.0/25;
#
# ここから新入りアタッカーを随時追加
# NOTE: https://www.abuseipdb.com/ で迷惑度を判定してから追加の判断をすると良いかも。
#
deny 37.115.0.0/16;
deny 41.216.186.0/24;
deny 42.189.140.0/24;
deny 50.117.117.122;
deny 66.240.205.34;
deny 77.247.110.60;
deny 81.22.0.0/16;
deny 83.235.178.0/24;
deny 83.242.128.0/17;
deny 92.118.37.91;
deny 103.244.0.0/22;
deny 110.249.212.46;
deny 117.34.111.215;
deny 154.218.1.0/24;
deny 178.137.80.0/20;
deny 185.234.219.239;
deny 188.166.103.213;
deny 201.99.54.67;
NOTE:ここでは全てdeny
(アクセス拒否) を使っていますが、allow
(アクセス許可) ももちろん使えます。
nginx設定ファイル
nginx設定ファイルnginx.conf
で先ほどの規制ファイルnginx-ip-restrictions.conf
を読込み:
# /etc/nginx/nginx.conf
user www-data;
...
http {
...
# IPアドレス規制ファイルを読み込み:
include /etc/nginx/nginx-ip-restrictions.conf; # <= この一行を追加!
}
nginx再起動
## 念のため設定ファイルに誤りがないかチェック:
$ nginx -t
## 再起動:
$ service nginx restart
お疲れ様でした。かなりお手軽ですが、たったこれだけでWebサーバへの不埒なアクセスを相当数弾くことができます。
IPアドレス規制ファイルは各自でカスタマイズすると良いでしょう。なおIPアドレス規制ファイルはこのページで随時更新していく予定です。
以上