Chặn dải IP Vietnam hoặc chỉ cho phép dải IP Việt Nam truy cập bằng htaccess hoặc nginx là tình huống có thể cần đến. Bài viết này, Biên Thùy hướng dẫn bạn làm việc đó.
Dải IP Việt Nam được mình lấy theo thông tin từ Github Vietnam IP Range
Có 2 phương pháp trên 2 loại server: Apache (với htaccess – Modrewrite) và Nginx (với Nginx config)
Lưu ý là nginx thì hầu như chỉ có trên VPS hay server riêng thì mình mới can thiệp được
Còn Apache thì hầu như shared hosting nào cũng hỗ trợ.
Chặn dải IP Vietnam (Không cho IP Việt Nam truy cập vào website của bạn)
1, Modrewrite (Apache – htaccess)
order allow,deny deny from 1.52.0.0/14 deny from 14.0.16.0/20 deny from 14.160.0.0/11 deny from 14.224.0.0/11 deny from 27.0.12.0/22 deny from 27.0.240.0/22 deny from 27.2.0.0/15 deny from 27.64.0.0/12 deny from 27.118.16.0/20 deny from 42.1.64.0/18 deny from 42.96.0.0/18 deny from 42.112.0.0/13 deny from 43.239.148.0/22 deny from 43.239.184.0/21 deny from 43.239.220.0/22 deny from 43.239.224.0/22 deny from 45.117.76.0/22 deny from 45.117.80.0/22 deny from 45.117.156.0/22 deny from 45.117.160.0/20 deny from 45.117.176.0/22 deny from 45.118.136.0/21 deny from 45.118.144.0/21 deny from 45.119.76.0/22 deny from 45.119.80.0/21 deny from 45.119.108.0/22 deny from 45.119.212.0/22 deny from 45.119.216.0/22 deny from 45.119.240.0/22 deny from 45.120.224.0/21 deny from 45.121.24.0/22 deny from 45.121.152.0/22 deny from 45.121.160.0/22 deny from 45.122.220.0/22 deny from 45.122.232.0/21 deny from 45.122.240.0/20 deny from 45.123.96.0/22 deny from 45.124.84.0/22 deny from 45.124.88.0/21 deny from 45.125.200.0/21 deny from 45.125.208.0/22 deny from 45.125.236.0/22 deny from 45.126.92.0/22 deny from 45.126.96.0/22 deny from 45.127.252.0/22 deny from 45.251.112.0/22 deny from 45.252.240.0/21 deny from 45.252.248.0/22 deny from 45.254.32.0/22 deny from 49.156.52.0/22 deny from 49.213.64.0/18 deny from 49.236.208.0/22 deny from 49.246.128.0/18 deny from 49.246.192.0/19 deny from 58.84.0.0/22 deny from 58.186.0.0/15 deny from 59.153.212.0/22 deny from 59.153.216.0/21 deny from 59.153.224.0/19 deny from 61.11.224.0/19 deny from 61.14.232.0/21 deny from 61.28.224.0/19 deny from 101.53.0.0/18 deny from 101.96.12.0/22 deny from 101.96.64.0/18 deny from 101.99.0.0/18 deny from 103.1.200.0/22 deny from 103.1.208.0/22 deny from 103.1.236.0/22 deny from 103.2.220.0/22 deny from 103.2.224.0/21 deny from 103.3.244.0/22 deny from 103.3.248.0/21 deny from 103.4.128.0/22 deny from 103.5.30.0/23 deny from 103.5.204.0/22 deny from 103.5.208.0/22 deny from 103.7.36.0/22 deny from 103.7.40.0/22 deny from 103.7.172.0/24 deny from 103.7.174.0/23 deny from 103.7.177.0/24 deny from 103.7.196.0/24 deny from 103.8.13.0/24 deny from 103.9.0.0/21 deny from 103.9.76.0/22 deny from 103.9.80.0/21 deny from 103.9.156.0/22 deny from 103.9.196.0/22 deny from 103.9.200.0/21 deny from 103.9.208.0/21 deny from 103.10.44.0/22 deny from 103.10.88.0/22 deny from 103.10.212.0/22 deny from 103.11.172.0/22 deny from 103.12.104.0/22 deny from 103.13.76.0/22 deny from 103.15.48.0/22 deny from 103.16.0.0/22 deny from 103.17.88.0/22 deny from 103.17.236.0/22 deny from 103.18.4.0/22 deny from 103.18.176.0/22 deny from 103.19.96.0/22 deny from 103.19.164.0/22 deny from 103.19.220.0/22 deny from 103.20.144.0/21 deny from 103.21.120.0/22 deny from 103.21.148.0/22 deny from 103.23.144.0/22 deny from 103.23.156.0/22 deny from 103.24.244.0/22 # Listed and share by BienThuy.Com deny from 103.26.252.0/22 deny from 103.27.60.0/22 deny from 103.27.64.0/22 deny from 103.27.236.0/22 deny from 103.28.32.0/21 deny from 103.28.136.0/22 deny from 103.28.172.0/22 deny from 103.30.36.0/22 deny from 103.31.120.0/21 deny from 103.35.64.0/22 deny from 103.37.28.0/22 deny from 103.37.32.0/22 deny from 103.38.136.0/22 deny from 103.39.92.0/22 deny from 103.39.96.0/22 deny from 103.42.56.0/22 deny from 103.45.228.0/22 deny from 103.45.232.0/21 deny from 103.47.192.0/22 deny from 103.48.76.0/22 deny from 103.48.80.0/21 deny from 103.48.188.0/22 deny from 103.48.192.0/22 deny from 103.52.92.0/22 deny from 103.53.88.0/22 deny from 103.53.168.0/22 deny from 103.53.228.0/22 deny from 103.53.252.0/22 deny from 103.54.248.0/21 deny from 103.56.156.0/22 deny from 103.56.160.0/21 deny from 103.56.168.0/22 deny from 103.57.104.0/22 deny from 103.57.112.0/22 deny from 103.57.208.0/22 deny from 103.57.220.0/22 deny from 103.60.16.0/22 deny from 103.61.44.0/22 deny from 103.61.48.0/22 deny from 103.62.8.0/22 deny from 103.63.104.0/21 deny from 103.63.112.0/21 deny from 103.63.120.0/22 deny from 103.63.212.0/22 deny from 103.66.152.0/22 deny from 103.68.68.0/22 deny from 103.68.72.0/21 deny from 103.68.80.0/22 deny from 103.68.240.0/20 deny from 103.69.188.0/22 deny from 103.69.192.0/22 deny from 103.70.28.0/22 deny from 103.71.180.0/22 deny from 103.71.184.0/22 deny from 103.72.96.0/22 deny from 103.74.100.0/22 deny from 103.74.104.0/22 deny from 103.74.112.0/21 deny from 103.74.120.0/22 deny from 103.75.176.0/21 deny from 103.75.184.0/22 deny from 103.77.160.0/21 deny from 103.77.168.0/22 deny from 103.78.76.0/22 deny from 103.78.84.0/22 deny from 103.78.88.0/21 deny from 103.79.140.0/22 deny from 103.79.144.0/22 deny from 103.81.80.0/21 deny from 103.82.20.0/22 deny from 103.82.24.0/21 deny from 103.82.32.0/21 deny from 103.82.132.0/22 deny from 103.82.192.0/21 deny from 103.82.204.0/23 deny from 103.84.76.0/22 deny from 103.87.220.0/22 deny from 103.88.108.0/22 deny from 103.88.112.0/21 deny from 103.88.120.0/22 deny from 103.89.84.0/22 deny from 103.89.88.0/21 deny from 103.89.120.0/22 deny from 103.90.220.0/22 deny from 103.90.224.0/21 deny from 103.90.232.0/22 deny from 103.92.24.0/21 deny from 103.92.32.0/22 deny from 103.94.16.0/22 deny from 103.94.176.0/22 deny from 103.95.156.0/22 deny from 103.95.168.0/22 deny from 103.95.196.0/22 deny from 103.97.124.0/22 deny from 103.97.132.0/22 deny from 103.192.236.0/22 deny from 103.194.188.0/22 deny from 103.195.236.0/22 deny from 103.195.240.0/22 deny from 103.196.16.0/22 deny from 103.196.236.0/22 deny from 103.196.244.0/22 deny from 103.196.248.0/22 deny from 103.199.4.0/22 deny from 103.199.8.0/21 deny from 103.199.16.0/20 deny from 103.199.32.0/19 deny from 103.199.64.0/20 deny from 103.200.20.0/22 deny from 103.200.24.0/22 deny from 103.200.60.0/22 deny from 103.200.120.0/22 deny from 103.205.96.0/21 deny from 103.205.104.0/22 deny from 103.206.212.0/22 deny from 103.206.216.0/22 deny from 103.207.32.0/21 deny from 103.211.212.0/22 deny from 103.213.122.0/23 deny from 103.214.8.0/22 deny from 103.216.72.0/22 # Listed and share by BienThuy.Com deny from 103.216.112.0/20 deny from 103.216.128.0/22 deny from 103.219.180.0/22 deny from 103.220.68.0/22 deny from 103.220.84.0/22 deny from 103.221.86.0/24 deny from 103.221.212.0/22 deny from 103.221.216.0/21 deny from 103.221.224.0/21 deny from 103.223.4.0/22 deny from 103.224.168.0/22 deny from 103.225.236.0/22 deny from 103.226.108.0/22 deny from 103.226.248.0/22 deny from 103.227.112.0/22 deny from 103.227.216.0/22 deny from 103.228.20.0/22 deny from 103.229.40.0/22 deny from 103.229.192.0/22 deny from 103.231.148.0/22 deny from 103.232.52.0/22 deny from 103.232.56.0/21 deny from 103.232.120.0/22 deny from 103.233.48.0/22 deny from 103.234.36.0/22 deny from 103.234.88.0/22 deny from 103.235.208.0/21 deny from 103.237.60.0/22 deny from 103.237.64.0/22 deny from 103.237.96.0/22 deny from 103.237.144.0/21 deny from 103.238.68.0/22 deny from 103.238.72.0/21 deny from 103.238.80.0/22 deny from 103.238.208.0/21 deny from 103.239.32.0/22 deny from 103.239.116.0/22 deny from 103.239.120.0/22 deny from 103.241.248.0/22 deny from 103.242.52.0/22 deny from 103.243.104.0/22 deny from 103.243.216.0/22 deny from 103.244.136.0/22 deny from 103.245.148.0/22 deny from 103.245.244.0/22 deny from 103.245.248.0/21 deny from 103.246.104.0/24 deny from 103.246.220.0/22 deny from 103.248.160.0/21 deny from 103.249.20.0/22 deny from 103.249.100.0/22 deny from 103.250.24.0/22 deny from 103.252.0.0/22 deny from 103.252.252.0/22 deny from 103.253.88.0/22 deny from 103.254.12.0/22 deny from 103.254.16.0/22 deny from 103.254.40.0/22 deny from 103.254.216.0/22 deny from 103.255.84.0/22 deny from 103.255.236.0/22 deny from 110.35.64.0/20 deny from 110.44.184.0/21 deny from 111.65.240.0/20 deny from 111.91.232.0/22 deny from 112.72.64.0/18 deny from 112.78.0.0/20 deny from 112.109.88.0/21 deny from 112.137.128.0/20 deny from 112.197.0.0/16 deny from 112.213.80.0/20 deny from 113.20.96.0/19 deny from 113.23.0.0/17 deny from 113.22.0.0/16 deny from 113.52.32.0/19 deny from 113.61.108.0/22 # Listed and share by BienThuy.Com deny from 113.160.0.0/11 deny from 115.72.0.0/13 deny from 115.84.176.0/21 deny from 115.146.120.0/21 deny from 115.165.160.0/21 deny from 116.68.128.0/21 deny from 116.96.0.0/12 deny from 116.118.0.0/17 deny from 116.193.64.0/20 deny from 116.212.32.0/19 deny from 117.0.0.0/13 deny from 117.103.192.0/18 deny from 117.122.0.0/17 deny from 118.68.0.0/14 deny from 118.102.0.0/21 deny from 118.107.64.0/18 deny from 119.15.160.0/19 deny from 119.17.192.0/18 deny from 119.18.128.0/20 deny from 119.18.184.0/21 deny from 119.82.128.0/20 deny from 120.50.184.0/21 deny from 120.72.80.0/21 deny from 120.72.96.0/19 deny from 120.138.64.0/20 deny from 121.50.172.0/22 deny from 122.102.112.0/22 deny from 122.129.0.0/18 deny from 122.201.8.0/21 deny from 123.16.0.0/12 deny from 124.157.0.0/18 deny from 124.158.0.0/20 deny from 125.58.0.0/18 deny from 125.212.128.0/17 deny from 125.214.0.0/18 deny from 125.234.0.0/15 deny from 125.253.112.0/20 deny from 137.59.24.0/21 deny from 137.59.32.0/20 deny from 137.59.104.0/22 deny from 137.59.116.0/22 deny from 144.48.20.0/22 deny from 144.48.24.0/22 deny from 146.196.64.0/22 deny from 150.95.16.0/22 deny from 150.95.104.0/21 deny from 150.95.112.0/20 deny from 157.119.244.0/22 deny from 157.119.248.0/22 deny from 163.44.192.0/22 deny from 163.44.200.0/24 deny from 163.44.204.0/22 deny from 171.224.0.0/11 deny from 175.103.64.0/18 deny from 175.106.0.0/22 deny from 180.93.0.0/16 deny from 180.148.0.0/21 deny from 180.148.128.0/20 deny from 180.214.236.0/22 deny from 182.161.80.0/20 deny from 182.236.112.0/22 deny from 182.237.20.0/22 deny from 183.81.0.0/17 deny from 183.80.0.0/16 deny from 183.90.160.0/21 deny from 183.91.0.0/19 deny from 183.91.160.0/19 deny from 202.0.79.0/24 deny from 202.4.168.0/24 deny from 202.4.176.0/24 deny from 202.6.2.0/24 deny from 202.6.96.0/23 deny from 202.9.79.0/24 deny from 202.9.80.0/24 deny from 202.9.84.0/24 deny from 202.37.86.0/23 deny from 202.43.108.0/22 deny from 202.44.137.0/24 deny from 202.47.87.0/24 deny from 202.47.142.0/24 deny from 202.52.39.0/24 deny from 202.55.132.0/22 deny from 202.56.57.0/24 deny from 202.58.245.0/24 deny from 202.59.238.0/23 deny from 202.59.252.0/23 deny from 202.60.104.0/21 deny from 202.74.56.0/24 deny from 202.74.58.0/23 deny from 202.78.224.0/21 deny from 202.79.232.0/21 deny from 202.87.212.0/22 deny from 202.92.4.0/22 deny from 202.93.156.0/22 deny from 202.94.82.0/24 deny from 202.94.88.0/23 deny from 202.124.204.0/24 deny from 202.130.36.0/23 deny from 202.134.16.0/21 deny from 202.134.54.0/24 deny from 202.143.108.0/22 deny from 202.151.160.0/20 deny from 202.158.244.0/22 deny from 202.160.124.0/23 deny from 202.172.4.0/23 deny from 202.191.56.0/22 deny from 203.8.127.0/24 deny from 203.8.172.0/24 deny from 203.34.144.0/24 deny from 203.77.178.0/24 deny from 203.79.28.0/24 deny from 203.89.140.0/22 deny from 203.99.248.0/22 deny from 203.113.128.0/18 deny from 203.119.8.0/22 deny from 203.119.36.0/22 deny from 203.119.44.0/22 deny from 203.119.58.0/23 deny from 203.119.60.0/22 deny from 203.119.64.0/21 deny from 203.119.72.0/22 deny from 203.128.240.0/21 deny from 203.160.0.0/23 deny from 203.160.96.0/21 deny from 203.160.132.0/22 deny from 203.161.178.0/24 deny from 203.162.0.0/16 deny from 203.163.128.0/18 deny from 203.167.8.0/21 deny from 203.170.26.0/23 deny from 203.171.16.0/20 deny from 203.176.160.0/21 deny from 203.189.28.0/22 deny from 203.190.160.0/20 deny from 203.191.8.0/21 deny from 203.191.48.0/21 deny from 203.195.0.0/18 deny from 203.196.24.0/22 deny from 203.201.56.0/22 deny from 203.205.0.0/18 deny from 203.209.180.0/22 deny from 203.210.128.0/17 deny from 210.2.64.0/18 deny from 210.86.224.0/20 deny from 210.211.96.0/19 deny from 210.245.0.0/17 deny from 218.100.10.0/24 deny from 218.100.14.0/24 deny from 218.100.60.0/24 deny from 220.231.64.0/18 deny from 221.121.0.0/18 deny from 221.132.0.0/18 deny from 221.133.0.0/19 deny from 222.252.0.0/14 deny from 223.27.104.0/21 # Allow all other IP not in the list allow from all
2, Nginx config
deny 1.52.0.0/14 deny 14.0.16.0/20 deny 14.160.0.0/11 deny 14.224.0.0/11 deny 27.0.12.0/22 deny 27.0.240.0/22 deny 27.2.0.0/15 deny 27.64.0.0/12 deny 27.118.16.0/20 deny 42.1.64.0/18 deny 42.96.0.0/18 deny 42.112.0.0/13 deny 43.239.148.0/22 deny 43.239.184.0/21 deny 43.239.220.0/22 deny 43.239.224.0/22 deny 45.117.76.0/22 deny 45.117.80.0/22 deny 45.117.156.0/22 deny 45.117.160.0/20 deny 45.117.176.0/22 deny 45.118.136.0/21 deny 45.118.144.0/21 deny 45.119.76.0/22 deny 45.119.80.0/21 deny 45.119.108.0/22 deny 45.119.212.0/22 deny 45.119.216.0/22 deny 45.119.240.0/22 deny 45.120.224.0/21 deny 45.121.24.0/22 deny 45.121.152.0/22 deny 45.121.160.0/22 deny 45.122.220.0/22 deny 45.122.232.0/21 deny 45.122.240.0/20 deny 45.123.96.0/22 deny 45.124.84.0/22 deny 45.124.88.0/21 deny 45.125.200.0/21 deny 45.125.208.0/22 deny 45.125.236.0/22 deny 45.126.92.0/22 deny 45.126.96.0/22 deny 45.127.252.0/22 deny 45.251.112.0/22 deny 45.252.240.0/21 deny 45.252.248.0/22 deny 45.254.32.0/22 deny 49.156.52.0/22 deny 49.213.64.0/18 deny 49.236.208.0/22 deny 49.246.128.0/18 deny 49.246.192.0/19 deny 58.84.0.0/22 deny 58.186.0.0/15 deny 59.153.212.0/22 deny 59.153.216.0/21 deny 59.153.224.0/19 deny 61.11.224.0/19 deny 61.14.232.0/21 deny 61.28.224.0/19 deny 101.53.0.0/18 deny 101.96.12.0/22 deny 101.96.64.0/18 deny 101.99.0.0/18 deny 103.1.200.0/22 deny 103.1.208.0/22 deny 103.1.236.0/22 deny 103.2.220.0/22 deny 103.2.224.0/21 deny 103.3.244.0/22 deny 103.3.248.0/21 deny 103.4.128.0/22 deny 103.5.30.0/23 deny 103.5.204.0/22 deny 103.5.208.0/22 deny 103.7.36.0/22 deny 103.7.40.0/22 deny 103.7.172.0/24 deny 103.7.174.0/23 deny 103.7.177.0/24 deny 103.7.196.0/24 deny 103.8.13.0/24 deny 103.9.0.0/21 deny 103.9.76.0/22 deny 103.9.80.0/21 deny 103.9.156.0/22 deny 103.9.196.0/22 deny 103.9.200.0/21 deny 103.9.208.0/21 deny 103.10.44.0/22 deny 103.10.88.0/22 deny 103.10.212.0/22 deny 103.11.172.0/22 deny 103.12.104.0/22 deny 103.13.76.0/22 deny 103.15.48.0/22 deny 103.16.0.0/22 deny 103.17.88.0/22 deny 103.17.236.0/22 deny 103.18.4.0/22 deny 103.18.176.0/22 deny 103.19.96.0/22 deny 103.19.164.0/22 deny 103.19.220.0/22 deny 103.20.144.0/21 deny 103.21.120.0/22 deny 103.21.148.0/22 deny 103.23.144.0/22 deny 103.23.156.0/22 deny 103.24.244.0/22 # Listed and share by BienThuy.Com deny 103.26.252.0/22 deny 103.27.60.0/22 deny 103.27.64.0/22 deny 103.27.236.0/22 deny 103.28.32.0/21 deny 103.28.136.0/22 deny 103.28.172.0/22 deny 103.30.36.0/22 deny 103.31.120.0/21 deny 103.35.64.0/22 deny 103.37.28.0/22 deny 103.37.32.0/22 deny 103.38.136.0/22 deny 103.39.92.0/22 deny 103.39.96.0/22 deny 103.42.56.0/22 deny 103.45.228.0/22 deny 103.45.232.0/21 deny 103.47.192.0/22 deny 103.48.76.0/22 deny 103.48.80.0/21 deny 103.48.188.0/22 deny 103.48.192.0/22 deny 103.52.92.0/22 deny 103.53.88.0/22 deny 103.53.168.0/22 deny 103.53.228.0/22 deny 103.53.252.0/22 deny 103.54.248.0/21 deny 103.56.156.0/22 deny 103.56.160.0/21 deny 103.56.168.0/22 deny 103.57.104.0/22 deny 103.57.112.0/22 deny 103.57.208.0/22 deny 103.57.220.0/22 deny 103.60.16.0/22 deny 103.61.44.0/22 deny 103.61.48.0/22 deny 103.62.8.0/22 deny 103.63.104.0/21 deny 103.63.112.0/21 deny 103.63.120.0/22 deny 103.63.212.0/22 deny 103.66.152.0/22 deny 103.68.68.0/22 deny 103.68.72.0/21 deny 103.68.80.0/22 deny 103.68.240.0/20 deny 103.69.188.0/22 deny 103.69.192.0/22 deny 103.70.28.0/22 deny 103.71.180.0/22 deny 103.71.184.0/22 deny 103.72.96.0/22 deny 103.74.100.0/22 deny 103.74.104.0/22 deny 103.74.112.0/21 deny 103.74.120.0/22 deny 103.75.176.0/21 deny 103.75.184.0/22 deny 103.77.160.0/21 deny 103.77.168.0/22 deny 103.78.76.0/22 deny 103.78.84.0/22 deny 103.78.88.0/21 deny 103.79.140.0/22 deny 103.79.144.0/22 deny 103.81.80.0/21 deny 103.82.20.0/22 deny 103.82.24.0/21 deny 103.82.32.0/21 deny 103.82.132.0/22 deny 103.82.192.0/21 deny 103.82.204.0/23 deny 103.84.76.0/22 deny 103.87.220.0/22 deny 103.88.108.0/22 deny 103.88.112.0/21 deny 103.88.120.0/22 deny 103.89.84.0/22 deny 103.89.88.0/21 deny 103.89.120.0/22 deny 103.90.220.0/22 deny 103.90.224.0/21 deny 103.90.232.0/22 deny 103.92.24.0/21 deny 103.92.32.0/22 deny 103.94.16.0/22 deny 103.94.176.0/22 deny 103.95.156.0/22 deny 103.95.168.0/22 deny 103.95.196.0/22 deny 103.97.124.0/22 deny 103.97.132.0/22 deny 103.192.236.0/22 deny 103.194.188.0/22 deny 103.195.236.0/22 deny 103.195.240.0/22 deny 103.196.16.0/22 deny 103.196.236.0/22 deny 103.196.244.0/22 deny 103.196.248.0/22 deny 103.199.4.0/22 deny 103.199.8.0/21 deny 103.199.16.0/20 deny 103.199.32.0/19 deny 103.199.64.0/20 deny 103.200.20.0/22 deny 103.200.24.0/22 deny 103.200.60.0/22 deny 103.200.120.0/22 deny 103.205.96.0/21 deny 103.205.104.0/22 deny 103.206.212.0/22 deny 103.206.216.0/22 deny 103.207.32.0/21 deny 103.211.212.0/22 deny 103.213.122.0/23 deny 103.214.8.0/22 deny 103.216.72.0/22 # Listed and share by BienThuy.Com deny 103.216.112.0/20 deny 103.216.128.0/22 deny 103.219.180.0/22 deny 103.220.68.0/22 deny 103.220.84.0/22 deny 103.221.86.0/24 deny 103.221.212.0/22 deny 103.221.216.0/21 deny 103.221.224.0/21 deny 103.223.4.0/22 deny 103.224.168.0/22 deny 103.225.236.0/22 deny 103.226.108.0/22 deny 103.226.248.0/22 deny 103.227.112.0/22 deny 103.227.216.0/22 deny 103.228.20.0/22 deny 103.229.40.0/22 deny 103.229.192.0/22 deny 103.231.148.0/22 deny 103.232.52.0/22 deny 103.232.56.0/21 deny 103.232.120.0/22 deny 103.233.48.0/22 deny 103.234.36.0/22 deny 103.234.88.0/22 deny 103.235.208.0/21 deny 103.237.60.0/22 deny 103.237.64.0/22 deny 103.237.96.0/22 deny 103.237.144.0/21 deny 103.238.68.0/22 deny 103.238.72.0/21 deny 103.238.80.0/22 deny 103.238.208.0/21 deny 103.239.32.0/22 deny 103.239.116.0/22 deny 103.239.120.0/22 deny 103.241.248.0/22 deny 103.242.52.0/22 deny 103.243.104.0/22 deny 103.243.216.0/22 deny 103.244.136.0/22 deny 103.245.148.0/22 deny 103.245.244.0/22 deny 103.245.248.0/21 deny 103.246.104.0/24 deny 103.246.220.0/22 deny 103.248.160.0/21 deny 103.249.20.0/22 deny 103.249.100.0/22 deny 103.250.24.0/22 deny 103.252.0.0/22 deny 103.252.252.0/22 deny 103.253.88.0/22 deny 103.254.12.0/22 deny 103.254.16.0/22 deny 103.254.40.0/22 deny 103.254.216.0/22 deny 103.255.84.0/22 deny 103.255.236.0/22 deny 110.35.64.0/20 deny 110.44.184.0/21 deny 111.65.240.0/20 deny 111.91.232.0/22 deny 112.72.64.0/18 deny 112.78.0.0/20 deny 112.109.88.0/21 deny 112.137.128.0/20 deny 112.197.0.0/16 deny 112.213.80.0/20 deny 113.20.96.0/19 deny 113.23.0.0/17 deny 113.22.0.0/16 deny 113.52.32.0/19 deny 113.61.108.0/22 # Listed and share by BienThuy.Com deny 113.160.0.0/11 deny 115.72.0.0/13 deny 115.84.176.0/21 deny 115.146.120.0/21 deny 115.165.160.0/21 deny 116.68.128.0/21 deny 116.96.0.0/12 deny 116.118.0.0/17 deny 116.193.64.0/20 deny 116.212.32.0/19 deny 117.0.0.0/13 deny 117.103.192.0/18 deny 117.122.0.0/17 deny 118.68.0.0/14 deny 118.102.0.0/21 deny 118.107.64.0/18 deny 119.15.160.0/19 deny 119.17.192.0/18 deny 119.18.128.0/20 deny 119.18.184.0/21 deny 119.82.128.0/20 deny 120.50.184.0/21 deny 120.72.80.0/21 deny 120.72.96.0/19 deny 120.138.64.0/20 deny 121.50.172.0/22 deny 122.102.112.0/22 deny 122.129.0.0/18 deny 122.201.8.0/21 deny 123.16.0.0/12 deny 124.157.0.0/18 deny 124.158.0.0/20 deny 125.58.0.0/18 deny 125.212.128.0/17 deny 125.214.0.0/18 deny 125.234.0.0/15 deny 125.253.112.0/20 deny 137.59.24.0/21 deny 137.59.32.0/20 deny 137.59.104.0/22 deny 137.59.116.0/22 deny 144.48.20.0/22 deny 144.48.24.0/22 deny 146.196.64.0/22 deny 150.95.16.0/22 deny 150.95.104.0/21 deny 150.95.112.0/20 deny 157.119.244.0/22 deny 157.119.248.0/22 deny 163.44.192.0/22 deny 163.44.200.0/24 deny 163.44.204.0/22 deny 171.224.0.0/11 deny 175.103.64.0/18 deny 175.106.0.0/22 deny 180.93.0.0/16 deny 180.148.0.0/21 deny 180.148.128.0/20 deny 180.214.236.0/22 deny 182.161.80.0/20 deny 182.236.112.0/22 deny 182.237.20.0/22 deny 183.81.0.0/17 deny 183.80.0.0/16 deny 183.90.160.0/21 deny 183.91.0.0/19 deny 183.91.160.0/19 deny 202.0.79.0/24 deny 202.4.168.0/24 deny 202.4.176.0/24 deny 202.6.2.0/24 deny 202.6.96.0/23 deny 202.9.79.0/24 deny 202.9.80.0/24 deny 202.9.84.0/24 deny 202.37.86.0/23 deny 202.43.108.0/22 deny 202.44.137.0/24 deny 202.47.87.0/24 deny 202.47.142.0/24 deny 202.52.39.0/24 deny 202.55.132.0/22 deny 202.56.57.0/24 deny 202.58.245.0/24 deny 202.59.238.0/23 deny 202.59.252.0/23 deny 202.60.104.0/21 deny 202.74.56.0/24 deny 202.74.58.0/23 deny 202.78.224.0/21 deny 202.79.232.0/21 deny 202.87.212.0/22 deny 202.92.4.0/22 deny 202.93.156.0/22 deny 202.94.82.0/24 deny 202.94.88.0/23 deny 202.124.204.0/24 deny 202.130.36.0/23 deny 202.134.16.0/21 deny 202.134.54.0/24 deny 202.143.108.0/22 deny 202.151.160.0/20 deny 202.158.244.0/22 deny 202.160.124.0/23 deny 202.172.4.0/23 deny 202.191.56.0/22 deny 203.8.127.0/24 deny 203.8.172.0/24 deny 203.34.144.0/24 deny 203.77.178.0/24 deny 203.79.28.0/24 deny 203.89.140.0/22 deny 203.99.248.0/22 deny 203.113.128.0/18 deny 203.119.8.0/22 deny 203.119.36.0/22 deny 203.119.44.0/22 deny 203.119.58.0/23 deny 203.119.60.0/22 deny 203.119.64.0/21 deny 203.119.72.0/22 deny 203.128.240.0/21 deny 203.160.0.0/23 deny 203.160.96.0/21 deny 203.160.132.0/22 deny 203.161.178.0/24 deny 203.162.0.0/16 deny 203.163.128.0/18 deny 203.167.8.0/21 deny 203.170.26.0/23 deny 203.171.16.0/20 deny 203.176.160.0/21 deny 203.189.28.0/22 deny 203.190.160.0/20 deny 203.191.8.0/21 deny 203.191.48.0/21 deny 203.195.0.0/18 deny 203.196.24.0/22 deny 203.201.56.0/22 deny 203.205.0.0/18 deny 203.209.180.0/22 deny 203.210.128.0/17 deny 210.2.64.0/18 deny 210.86.224.0/20 deny 210.211.96.0/19 deny 210.245.0.0/17 deny 218.100.10.0/24 deny 218.100.14.0/24 deny 218.100.60.0/24 deny 220.231.64.0/18 deny 221.121.0.0/18 deny 221.132.0.0/18 deny 221.133.0.0/19 deny 222.252.0.0/14 deny 223.27.104.0/21
Chỉ cho phép IP Việt Nam truy cập – Chặn tất cả phần còn lại
1, Modrewrite (Apache – htaccess)
order deny,allow allow from 1.52.0.0/14 allow from 14.0.16.0/20 allow from 14.160.0.0/11 allow from 14.224.0.0/11 allow from 27.0.12.0/22 allow from 27.0.240.0/22 allow from 27.2.0.0/15 allow from 27.64.0.0/12 allow from 27.118.16.0/20 allow from 42.1.64.0/18 allow from 42.96.0.0/18 allow from 42.112.0.0/13 allow from 43.239.148.0/22 allow from 43.239.184.0/21 allow from 43.239.220.0/22 allow from 43.239.224.0/22 allow from 45.117.76.0/22 allow from 45.117.80.0/22 allow from 45.117.156.0/22 allow from 45.117.160.0/20 allow from 45.117.176.0/22 allow from 45.118.136.0/21 allow from 45.118.144.0/21 allow from 45.119.76.0/22 allow from 45.119.80.0/21 allow from 45.119.108.0/22 allow from 45.119.212.0/22 allow from 45.119.216.0/22 allow from 45.119.240.0/22 allow from 45.120.224.0/21 allow from 45.121.24.0/22 allow from 45.121.152.0/22 allow from 45.121.160.0/22 allow from 45.122.220.0/22 allow from 45.122.232.0/21 allow from 45.122.240.0/20 allow from 45.123.96.0/22 allow from 45.124.84.0/22 allow from 45.124.88.0/21 allow from 45.125.200.0/21 allow from 45.125.208.0/22 allow from 45.125.236.0/22 allow from 45.126.92.0/22 allow from 45.126.96.0/22 allow from 45.127.252.0/22 allow from 45.251.112.0/22 allow from 45.252.240.0/21 allow from 45.252.248.0/22 allow from 45.254.32.0/22 allow from 49.156.52.0/22 allow from 49.213.64.0/18 allow from 49.236.208.0/22 allow from 49.246.128.0/18 allow from 49.246.192.0/19 allow from 58.84.0.0/22 allow from 58.186.0.0/15 allow from 59.153.212.0/22 allow from 59.153.216.0/21 allow from 59.153.224.0/19 allow from 61.11.224.0/19 allow from 61.14.232.0/21 allow from 61.28.224.0/19 allow from 101.53.0.0/18 allow from 101.96.12.0/22 allow from 101.96.64.0/18 allow from 101.99.0.0/18 allow from 103.1.200.0/22 allow from 103.1.208.0/22 allow from 103.1.236.0/22 allow from 103.2.220.0/22 allow from 103.2.224.0/21 allow from 103.3.244.0/22 allow from 103.3.248.0/21 allow from 103.4.128.0/22 allow from 103.5.30.0/23 allow from 103.5.204.0/22 allow from 103.5.208.0/22 allow from 103.7.36.0/22 allow from 103.7.40.0/22 allow from 103.7.172.0/24 allow from 103.7.174.0/23 allow from 103.7.177.0/24 allow from 103.7.196.0/24 allow from 103.8.13.0/24 allow from 103.9.0.0/21 allow from 103.9.76.0/22 allow from 103.9.80.0/21 allow from 103.9.156.0/22 allow from 103.9.196.0/22 allow from 103.9.200.0/21 allow from 103.9.208.0/21 allow from 103.10.44.0/22 allow from 103.10.88.0/22 allow from 103.10.212.0/22 allow from 103.11.172.0/22 allow from 103.12.104.0/22 allow from 103.13.76.0/22 allow from 103.15.48.0/22 allow from 103.16.0.0/22 allow from 103.17.88.0/22 allow from 103.17.236.0/22 allow from 103.18.4.0/22 allow from 103.18.176.0/22 allow from 103.19.96.0/22 allow from 103.19.164.0/22 allow from 103.19.220.0/22 allow from 103.20.144.0/21 allow from 103.21.120.0/22 allow from 103.21.148.0/22 allow from 103.23.144.0/22 allow from 103.23.156.0/22 allow from 103.24.244.0/22 allow from 103.26.252.0/22 allow from 103.27.60.0/22 allow from 103.27.64.0/22 allow from 103.27.236.0/22 allow from 103.28.32.0/21 allow from 103.28.136.0/22 allow from 103.28.172.0/22 allow from 103.30.36.0/22 allow from 103.31.120.0/21 allow from 103.35.64.0/22 allow from 103.37.28.0/22 allow from 103.37.32.0/22 allow from 103.38.136.0/22 allow from 103.39.92.0/22 allow from 103.39.96.0/22 allow from 103.42.56.0/22 allow from 103.45.228.0/22 allow from 103.45.232.0/21 allow from 103.47.192.0/22 allow from 103.48.76.0/22 allow from 103.48.80.0/21 allow from 103.48.188.0/22 allow from 103.48.192.0/22 allow from 103.52.92.0/22 allow from 103.53.88.0/22 allow from 103.53.168.0/22 allow from 103.53.228.0/22 allow from 103.53.252.0/22 allow from 103.54.248.0/21 allow from 103.56.156.0/22 allow from 103.56.160.0/21 allow from 103.56.168.0/22 allow from 103.57.104.0/22 allow from 103.57.112.0/22 allow from 103.57.208.0/22 allow from 103.57.220.0/22 allow from 103.60.16.0/22 allow from 103.61.44.0/22 allow from 103.61.48.0/22 allow from 103.62.8.0/22 allow from 103.63.104.0/21 allow from 103.63.112.0/21 allow from 103.63.120.0/22 allow from 103.63.212.0/22 allow from 103.66.152.0/22 allow from 103.68.68.0/22 allow from 103.68.72.0/21 allow from 103.68.80.0/22 allow from 103.68.240.0/20 allow from 103.69.188.0/22 allow from 103.69.192.0/22 allow from 103.70.28.0/22 allow from 103.71.180.0/22 allow from 103.71.184.0/22 allow from 103.72.96.0/22 allow from 103.74.100.0/22 allow from 103.74.104.0/22 allow from 103.74.112.0/21 allow from 103.74.120.0/22 allow from 103.75.176.0/21 allow from 103.75.184.0/22 allow from 103.77.160.0/21 allow from 103.77.168.0/22 allow from 103.78.76.0/22 allow from 103.78.84.0/22 allow from 103.78.88.0/21 allow from 103.79.140.0/22 allow from 103.79.144.0/22 allow from 103.81.80.0/21 allow from 103.82.20.0/22 allow from 103.82.24.0/21 allow from 103.82.32.0/21 allow from 103.82.132.0/22 allow from 103.82.192.0/21 allow from 103.82.204.0/23 allow from 103.84.76.0/22 allow from 103.87.220.0/22 allow from 103.88.108.0/22 allow from 103.88.112.0/21 allow from 103.88.120.0/22 # Listed and share by BienThuy.Com allow from 103.89.84.0/22 allow from 103.89.88.0/21 allow from 103.89.120.0/22 allow from 103.90.220.0/22 allow from 103.90.224.0/21 allow from 103.90.232.0/22 allow from 103.92.24.0/21 allow from 103.92.32.0/22 allow from 103.94.16.0/22 allow from 103.94.176.0/22 allow from 103.95.156.0/22 allow from 103.95.168.0/22 allow from 103.95.196.0/22 allow from 103.97.124.0/22 allow from 103.97.132.0/22 allow from 103.192.236.0/22 allow from 103.194.188.0/22 allow from 103.195.236.0/22 allow from 103.195.240.0/22 allow from 103.196.16.0/22 allow from 103.196.236.0/22 allow from 103.196.244.0/22 allow from 103.196.248.0/22 allow from 103.199.4.0/22 allow from 103.199.8.0/21 allow from 103.199.16.0/20 allow from 103.199.32.0/19 allow from 103.199.64.0/20 allow from 103.200.20.0/22 allow from 103.200.24.0/22 allow from 103.200.60.0/22 allow from 103.200.120.0/22 allow from 103.205.96.0/21 allow from 103.205.104.0/22 allow from 103.206.212.0/22 allow from 103.206.216.0/22 allow from 103.207.32.0/21 allow from 103.211.212.0/22 allow from 103.213.122.0/23 allow from 103.214.8.0/22 allow from 103.216.72.0/22 allow from 103.216.112.0/20 allow from 103.216.128.0/22 allow from 103.219.180.0/22 allow from 103.220.68.0/22 allow from 103.220.84.0/22 allow from 103.221.86.0/24 allow from 103.221.212.0/22 allow from 103.221.216.0/21 allow from 103.221.224.0/21 allow from 103.223.4.0/22 allow from 103.224.168.0/22 allow from 103.225.236.0/22 allow from 103.226.108.0/22 allow from 103.226.248.0/22 allow from 103.227.112.0/22 allow from 103.227.216.0/22 allow from 103.228.20.0/22 allow from 103.229.40.0/22 allow from 103.229.192.0/22 allow from 103.231.148.0/22 allow from 103.232.52.0/22 allow from 103.232.56.0/21 allow from 103.232.120.0/22 allow from 103.233.48.0/22 allow from 103.234.36.0/22 allow from 103.234.88.0/22 allow from 103.235.208.0/21 allow from 103.237.60.0/22 allow from 103.237.64.0/22 allow from 103.237.96.0/22 allow from 103.237.144.0/21 allow from 103.238.68.0/22 allow from 103.238.72.0/21 allow from 103.238.80.0/22 allow from 103.238.208.0/21 allow from 103.239.32.0/22 allow from 103.239.116.0/22 allow from 103.239.120.0/22 allow from 103.241.248.0/22 allow from 103.242.52.0/22 allow from 103.243.104.0/22 allow from 103.243.216.0/22 allow from 103.244.136.0/22 allow from 103.245.148.0/22 allow from 103.245.244.0/22 allow from 103.245.248.0/21 allow from 103.246.104.0/24 allow from 103.246.220.0/22 allow from 103.248.160.0/21 allow from 103.249.20.0/22 allow from 103.249.100.0/22 allow from 103.250.24.0/22 allow from 103.252.0.0/22 allow from 103.252.252.0/22 allow from 103.253.88.0/22 allow from 103.254.12.0/22 allow from 103.254.16.0/22 allow from 103.254.40.0/22 allow from 103.254.216.0/22 allow from 103.255.84.0/22 allow from 103.255.236.0/22 allow from 110.35.64.0/20 allow from 110.44.184.0/21 allow from 111.65.240.0/20 allow from 111.91.232.0/22 allow from 112.72.64.0/18 allow from 112.78.0.0/20 allow from 112.109.88.0/21 allow from 112.137.128.0/20 # Listed and share by BienThuy.Com allow from 112.197.0.0/16 allow from 112.213.80.0/20 allow from 113.20.96.0/19 allow from 113.23.0.0/17 allow from 113.22.0.0/16 allow from 113.52.32.0/19 allow from 113.61.108.0/22 allow from 113.160.0.0/11 allow from 115.72.0.0/13 allow from 115.84.176.0/21 allow from 115.146.120.0/21 allow from 115.165.160.0/21 allow from 116.68.128.0/21 allow from 116.96.0.0/12 allow from 116.118.0.0/17 allow from 116.193.64.0/20 allow from 116.212.32.0/19 allow from 117.0.0.0/13 allow from 117.103.192.0/18 allow from 117.122.0.0/17 allow from 118.68.0.0/14 allow from 118.102.0.0/21 allow from 118.107.64.0/18 allow from 119.15.160.0/19 allow from 119.17.192.0/18 allow from 119.18.128.0/20 allow from 119.18.184.0/21 allow from 119.82.128.0/20 allow from 120.50.184.0/21 allow from 120.72.80.0/21 allow from 120.72.96.0/19 allow from 120.138.64.0/20 allow from 121.50.172.0/22 allow from 122.102.112.0/22 allow from 122.129.0.0/18 allow from 122.201.8.0/21 allow from 123.16.0.0/12 allow from 124.157.0.0/18 allow from 124.158.0.0/20 allow from 125.58.0.0/18 allow from 125.212.128.0/17 allow from 125.214.0.0/18 allow from 125.234.0.0/15 allow from 125.253.112.0/20 allow from 137.59.24.0/21 allow from 137.59.32.0/20 allow from 137.59.104.0/22 allow from 137.59.116.0/22 allow from 144.48.20.0/22 allow from 144.48.24.0/22 allow from 146.196.64.0/22 allow from 150.95.16.0/22 allow from 150.95.104.0/21 allow from 150.95.112.0/20 allow from 157.119.244.0/22 allow from 157.119.248.0/22 allow from 163.44.192.0/22 allow from 163.44.200.0/24 allow from 163.44.204.0/22 allow from 171.224.0.0/11 allow from 175.103.64.0/18 allow from 175.106.0.0/22 allow from 180.93.0.0/16 allow from 180.148.0.0/21 allow from 180.148.128.0/20 allow from 180.214.236.0/22 allow from 182.161.80.0/20 allow from 182.236.112.0/22 allow from 182.237.20.0/22 allow from 183.81.0.0/17 allow from 183.80.0.0/16 allow from 183.90.160.0/21 allow from 183.91.0.0/19 allow from 183.91.160.0/19 allow from 202.0.79.0/24 allow from 202.4.168.0/24 allow from 202.4.176.0/24 allow from 202.6.2.0/24 allow from 202.6.96.0/23 allow from 202.9.79.0/24 allow from 202.9.80.0/24 allow from 202.9.84.0/24 allow from 202.37.86.0/23 allow from 202.43.108.0/22 allow from 202.44.137.0/24 allow from 202.47.87.0/24 allow from 202.47.142.0/24 allow from 202.52.39.0/24 allow from 202.55.132.0/22 allow from 202.56.57.0/24 allow from 202.58.245.0/24 allow from 202.59.238.0/23 allow from 202.59.252.0/23 allow from 202.60.104.0/21 allow from 202.74.56.0/24 allow from 202.74.58.0/23 allow from 202.78.224.0/21 allow from 202.79.232.0/21 allow from 202.87.212.0/22 allow from 202.92.4.0/22 # Listed and share by BienThuy.Com allow from 202.93.156.0/22 allow from 202.94.82.0/24 allow from 202.94.88.0/23 allow from 202.124.204.0/24 allow from 202.130.36.0/23 allow from 202.134.16.0/21 allow from 202.134.54.0/24 allow from 202.143.108.0/22 allow from 202.151.160.0/20 allow from 202.158.244.0/22 allow from 202.160.124.0/23 allow from 202.172.4.0/23 allow from 202.191.56.0/22 allow from 203.8.127.0/24 allow from 203.8.172.0/24 allow from 203.34.144.0/24 allow from 203.77.178.0/24 allow from 203.79.28.0/24 allow from 203.89.140.0/22 allow from 203.99.248.0/22 allow from 203.113.128.0/18 allow from 203.119.8.0/22 allow from 203.119.36.0/22 allow from 203.119.44.0/22 allow from 203.119.58.0/23 allow from 203.119.60.0/22 allow from 203.119.64.0/21 allow from 203.119.72.0/22 allow from 203.128.240.0/21 allow from 203.160.0.0/23 allow from 203.160.96.0/21 allow from 203.160.132.0/22 allow from 203.161.178.0/24 allow from 203.162.0.0/16 allow from 203.163.128.0/18 allow from 203.167.8.0/21 allow from 203.170.26.0/23 allow from 203.171.16.0/20 allow from 203.176.160.0/21 allow from 203.189.28.0/22 allow from 203.190.160.0/20 allow from 203.191.8.0/21 allow from 203.191.48.0/21 allow from 203.195.0.0/18 allow from 203.196.24.0/22 allow from 203.201.56.0/22 allow from 203.205.0.0/18 allow from 203.209.180.0/22 allow from 203.210.128.0/17 allow from 210.2.64.0/18 allow from 210.86.224.0/20 allow from 210.211.96.0/19 allow from 210.245.0.0/17 allow from 218.100.10.0/24 allow from 218.100.14.0/24 allow from 218.100.60.0/24 allow from 220.231.64.0/18 allow from 221.121.0.0/18 allow from 221.132.0.0/18 allow from 221.133.0.0/19 allow from 222.252.0.0/14 allow from 223.27.104.0/21 # Deny all other IP not in the list deny from all
2, Nginx config
Bạn chỉ việc copy phần code bên trên dán vào đầu file htaccess
Hoặc trong nginx.conf thì tìm đoạn này:
location / {
và thay thành thế này
location / { # Block this IP: 123.123.123.123 deny 123.123.123.123; ## Other config of yours
Hoặc cách khác là include file
Bạn save cái nginx config bên trên mình đưa thành 1 file gọi là block-ip.conf
Sau đó include file block-ip.conf vào nginx.conf thế này
include block-ip.conf;
Có vấn đề gì bị lỗi thì comment hoặc liên hệ mình để mình giúp nhé
Các bạn đón đọc các bài viết về chủ đề “Block country access to Website” sẽ update cách làm và danh sách IP của nhiều quốc gia như: Poland, Ukraina, Indonesia, Vietnam, Russia, India, Brazil, Colombia, Turkey, China…