# known IPs of any DNS located in China: china = { "1.1.8.8", "1.1.8.9", "1.2.4.8", "1.8.1.8", "1.8.8.8", "58.21.129.224", "58.213.28.126", "58.221.250.86", "58.222.226.146", "112.67.171.231", "114.254.201.131", "180.76.76.76", "180.163.223.236", # "202.57.32.49", # not china but seems to be poisoned # "204.13.152.3", # likewise "210.2.4.8", "218.94.128.126", "218.94.193.170", "218.107.55.108", "221.231.0.210", "222.92.244.250", "222.216.2.236", } # known IPs (not servers) that are used to deny access to websites: blocks = { "1.2.3.4", # timeout "3.215.231.251", "5.129.186.222", "27.54.116.70", "31.204.161.41", "34.218.72.125", "36.86.63.185", "49.128.177.13", "52.15.96.207", "52.25.92.0", "54.65.172.3", "54.242.237.204", "62.77.154.37", "62.85.160.222", "62.113.48.25", "64.13.192.76", "64.13.232.149", "75.2.78.201", "85.214.151.164", "91.195.127.75", "93.158.134.250", "94.140.14.33", "95.77.94.80", "99.83.232.37", "101.255.0.226", "101.255.1.226", "103.10.121.34", "103.87.69.47", "103.144.182.26", "103.144.182.27", "104.16.252.55", "104.244.43.104", "104.244.43.228", "114.6.128.8", "118.97.116.27", "119.235.28.59", "119.235.29.59", "124.40.255.100", "124.40.255.99", "125.26.170.3", "146.112.61.104", "146.112.61.105", "146.112.61.106", "146.112.61.107", "146.112.61.108", "146.112.61.109", "146.112.61.110", "146.112.61.111", "146.112.61.112", "146.112.61.113", "149.28.172.145", "157.240.3.50", "157.240.17.14", "157.240.21.9", "162.241.226.169", "163.28.10.160", "165.21.74.4", "175.139.142.25", "176.103.130.130", "176.103.130.131", "176.103.130.132", "176.103.130.133", "176.103.130.134", "176.103.130.135", "182.93.64.126", "188.186.157.49", "192.99.140.48", "193.58.251.1", "195.46.39.1", "195.175.254.2", "195.186.208.169", "195.208.152.206", "195.234.22.137", "199.59.150.11", "202.40.187.91", "202.51.96.6", "202.152.0.14", "202.162.209.133", "202.165.36.253", "202.165.36.42", "202.169.44.80", "203.119.13.75", "203.119.13.76", "203.119.13.77", "203.119.13.78", "203.190.55.217", "203.195.99.1", "213.177.28.90", "213.224.83.39", "217.175.53.72", # i don't remember if this is where NXDOMAIN redirects go, but: "10.10.34.35", "23.60.91.225", "23.60.91.230", "23.200.237.225", "23.200.237.230", "23.202.231.167", "23.217.138.108", "154.72.193.28", "198.105.244.23", "198.105.254.23", # TODO: timeouts, rejections: # "58.217.249.141", # "62.2.16.116", # "62.33.207.196", # "62.33.207.197", # "67.228.235.91", # "67.228.235.93", # "89.23.201.131", # "93.46.8.89", # "119.235.28.59", # "192.121.44.204", # "199.16.158.190", # "211.233.91.10", # this showed up for the sinkhole. it's an error page, but is it wrong? # "159.100.251.128", # this might be a sinkhole as well? gives 404 for non-sinkhole domains. # "212.179.240.96", # timeout for the sinkhole... not a good sign. # "116.31.102.47", } block_checks = [ "156.154.112.", "156.154.113.", "156.154.175.", "156.154.176.", ] gfw_ips = { "4.36.66.178", "8.7.198.45", "8.7.198.46", "23.89.5.60", "23.101.24.70", "23.225.141.210", "23.234.30.58", "27.40.141.40", "38.121.72.166", "39.109.122.128", "45.114.11.25", "45.114.11.238", "46.82.174.68", "46.82.174.69", "47.88.58.234", "49.2.123.56", "50.87.93.246", "52.58.1.161", "52.175.9.80", "54.76.135.1", "54.89.135.129", "54.234.18.200", "54.245.22.188", "59.24.3.173", "59.24.3.174", "59.188.250.54", "65.49.68.152", "66.220.146.94", "66.220.147.11", "66.220.147.47", "66.220.149.18", "66.220.149.32", "66.220.149.99", "66.220.151.20", "66.220.152.17", "66.220.155.12", "66.220.155.14", "66.220.158.32", "67.15.100.252", "67.15.129.210", "67.228.102.32", "67.228.235.91", "67.228.235.93", "67.230.169.182", "69.63.176.15", "69.63.176.59", "69.63.176.143", "69.63.178.13", "69.63.180.173", "69.63.181.11", "69.63.181.12", "69.63.184.14", "69.63.184.30", "69.63.184.142", "69.63.186.30", "69.63.186.31", "69.63.187.12", "69.63.189.16", "69.63.190.26", "74.86.3.208", "74.86.12.172", "74.86.12.173", "74.86.17.48", "74.86.118.24", "74.86.142.55", "74.86.151.162", "74.86.151.167", "74.86.226.234", "74.86.228.110", "75.126.2.43", "75.126.33.156", "75.126.115.192", "75.126.124.162", "75.126.135.131", "75.126.150.210", "75.126.164.178", "75.126.215.88", "77.4.7.92", "78.16.49.15", "88.191.249.182", "88.191.249.183", "88.191.253.157", "93.46.8.89", "93.46.8.90", "93.179.102.140", "98.159.108.57", "98.159.108.58", "98.159.108.61", "98.159.108.71", "103.39.76.66", "103.42.176.244", "103.56.16.112", "103.73.161.52", "103.97.3.19", "103.97.176.73", "103.200.30.143", "103.200.30.245", "103.200.31.172", "103.214.168.106", "103.226.246.99", "103.228.130.27", "103.228.130.61", "103.230.123.190", "103.240.180.117", "103.240.182.55", "103.246.246.144", "103.252.114.11", "103.252.114.61", "103.252.114.101", "103.252.115.49", "103.252.115.53", "103.252.115.59", "103.252.115.153", "103.252.115.157", "103.252.115.165", "103.252.115.169", "103.252.115.221", "104.244.46.5", "104.244.46.9", "104.244.46.17", "104.244.46.21", "104.244.46.52", "104.244.46.57", "104.244.46.63", "104.244.46.71", "104.244.46.85", "104.244.46.93", "104.244.46.165", "104.244.46.172", "104.244.46.185", "104.244.46.186", "104.244.46.208", "104.244.46.211", "104.244.46.244", "104.244.46.246", "107.181.166.244", "111.243.214.169", "114.43.24.59", "115.126.100.160", "118.107.180.216", "118.184.26.113", "118.184.78.78", "118.193.202.219", "118.193.240.37", "118.193.240.41", "119.28.87.227", "122.10.85.4", "124.11.210.175", "128.121.146.101", "128.121.146.109", "128.121.146.228", "128.121.146.235", "128.121.243.228", "128.121.243.235", "128.242.240.20", "128.242.240.59", "128.242.240.85", "128.242.240.91", "128.242.240.117", "128.242.240.149", "128.242.240.155", "148.163.48.215", "150.107.3.176", "154.83.14.134", "154.83.15.20", "154.83.15.45", "154.85.102.30", "154.85.102.32", "154.92.16.97", "156.233.67.243", "157.240.1.33", "157.240.2.14", "157.240.3.8", "157.240.7.5", "157.240.8.41", "157.240.10.32", "157.240.10.41", "157.240.15.8", "157.240.17.36", "157.240.17.41", "157.240.17.50", "159.138.20.20", "162.125.17.131", "162.125.18.129", "162.125.18.133", "162.125.32.2", "162.125.32.5", "162.125.32.6", "162.125.32.9", "162.125.32.10", "162.125.32.12", "162.125.32.13", "162.125.32.15", "162.125.34.133", "162.220.12.226", "173.244.209.150", "173.244.217.42", "173.252.73.48", "173.252.88.67", "173.252.88.133", "173.252.100.21", "173.252.100.32", "173.252.102.16", "173.252.102.241", "173.252.103.64", "173.252.108.3", "173.252.110.21", "174.36.196.242", "174.36.228.136", "174.37.54.20", "174.37.154.236", "174.37.175.229", "174.37.243.85", "179.60.193.9", "179.60.193.16", "184.173.136.86", "185.45.6.57", "185.45.6.103", "185.45.7.97", "185.45.7.165", "185.45.7.185", "185.45.7.189", "185.60.216.11", "185.60.219.41", "188.5.4.96", "192.133.77.59", "192.133.77.133", "192.133.77.145", "192.133.77.189", "192.133.77.191", "192.133.77.197", "197.4.4.12", "198.27.124.186", "198.44.185.131", "199.16.158.190", "199.59.148.97", "199.59.148.209", "199.59.149.136", "199.59.149.244", "199.59.150.49", "199.96.58.15", "199.96.58.85", "199.96.58.105", "199.96.58.157", "199.96.58.177", "199.96.59.19", "199.96.59.61", "199.96.59.95", "199.96.62.17", "199.96.62.21", "199.96.62.41", "199.96.62.75", "199.96.63.53", "199.96.63.75", "199.96.63.163", "199.96.63.177", "202.53.137.209", "202.160.128.14", "202.160.128.16", "202.160.128.40", "202.160.128.96", "202.160.128.195", "202.160.128.203", "202.160.128.205", "202.160.128.210", "202.160.128.238", "202.160.129.6", "202.160.129.36", "202.160.129.37", "202.160.129.164", "202.160.130.7", "202.160.130.52", "202.160.130.66", "202.160.130.117", "202.160.130.118", "202.160.130.145", "202.182.98.125", "203.98.7.65", "203.111.254.117", "203.161.230.171", "205.186.152.122", "208.31.254.33", "208.43.170.231", "208.43.237.140", "208.77.47.172", "208.101.21.43", "208.101.60.87", "209.95.56.60", "210.56.51.192", "210.56.51.193", "210.209.84.142", "211.104.160.39", "243.185.187.39", "249.129.46.48", "253.157.14.165", } bogon_checks = [ "0.", "10.", "127.", "169.254.", "192.0.0.", "192.0.2.", "192.168.", "198.18.", "198.19.", "198.51.100.", "203.0.113.", ] + [ "100.{}.".format(i) for i in range(64, 128) ] + [ "172.{}.".format(i) for i in range(16, 32) ] + [ "{}.".format(i) for i in range(224, 256) ] def is_bogon(ip): return any(ip.startswith(check) for check in bogon_checks) def is_block_target(ip): if ip in blocks: return True return any(ip.startswith(check) for check in block_checks)