文章

CloudFlare 自选IP测试

在搭建*2**yN服务器时,因反向代理需要用到CF的自选IP,在网上搜寻发现有很多IP都已失效了。于是自己搞了个代码测试了一下,供大家使用。

首先进入CloudFlare的官方IP list:IP Ranges | Cloudflare

您可以在这里看到CF最近更新的IP地址库。当然,您也可以点击IPv4 text list以及IPv6 text list来查看以txt形式呈现的IP列表。

考虑到IPv4普及度较高,这里就以IPv4进行测试。

把IP地址都复制下来,编辑进代码里:

from ping3 import ping

def p(ip):
    ip_address = ip
    response = ping(ip_address)
    if response is not None:
        delay = int(response * 1000)
        return delay
    else:
        return 2333


l=[
"173.245.48.0/20",
"103.21.244.0/22",
"103.22.200.0/22",
"103.31.4.0/22",
"141.101.64.0/18",
"108.162.192.0/18",
"190.93.240.0/20",
"188.114.96.0/20",
"197.234.240.0/22",
"198.41.128.0/17",
"162.158.0.0/15",
"172.64.0.0/13",
"131.0.72.0/22",
"104.16.0.0/13",
"104.24.0.0/14"
]

for i in l:
    root=i[:i.rfind(".")]+'.'
    j=0
    while j<=int(i[i.find("/")+1:]):
        j+=1
        b = p(str(root)+str(j))
        if(b==2333):
            print(str(root)+str(j),"×")
        else:
            print(str(root)+str(j),b)

然后慢慢运行。笔者本地的网络运营商是电信,一下数据可供您参考:

173.245.48.1 184
173.245.48.2 ×
173.245.48.3 ×
173.245.48.4 ×
173.245.48.5 ×
173.245.48.6 ×
173.245.48.7 ×
173.245.48.8 ×
173.245.48.9 ×
173.245.48.10 ×
173.245.48.11 ×
173.245.48.12 ×
173.245.48.13 ×
173.245.48.14 ×
173.245.48.15 ×
173.245.48.16 ×
173.245.48.17 ×
173.245.48.18 ×
173.245.48.19 ×
173.245.48.20 ×
173.245.48.21 ×
103.21.244.1 221
103.21.244.2 254
103.21.244.3 237
103.21.244.4 261
103.21.244.5 221
103.21.244.6 240
103.21.244.7 218
103.21.244.8 240
103.21.244.9 238
103.21.244.10 258
103.21.244.11 224
103.21.244.12 241
103.21.244.13 238
103.21.244.14 287
103.21.244.15 240
103.21.244.16 238
103.21.244.17 239
103.21.244.18 240
103.21.244.19 247
103.21.244.20 242
103.21.244.21 261
103.21.244.22 279
103.21.244.23 238
103.22.200.1 155
103.22.200.2 ×
103.22.200.3 ×
103.22.200.4 ×
103.22.200.5 ×
103.22.200.6 ×
103.22.200.7 ×
103.22.200.8 ×
103.22.200.9 ×
103.22.200.10 ×
103.22.200.11 ×
103.22.200.12 ×
103.22.200.13 ×
103.22.200.14 ×
103.22.200.15 ×
103.22.200.16 ×
103.22.200.17 ×
103.22.200.18 ×
103.22.200.19 ×
103.22.200.20 ×
103.22.200.21 ×
103.22.200.22 ×
103.22.200.23 ×
103.31.4.1 ×
103.31.4.2 ×
103.31.4.3 ×
103.31.4.4 ×
103.31.4.5 ×
103.31.4.6 ×
103.31.4.7 ×
103.31.4.8 ×
103.31.4.9 ×
103.31.4.10 ×
103.31.4.11 ×
103.31.4.12 ×
103.31.4.13 ×
103.31.4.14 ×
103.31.4.15 ×
103.31.4.16 ×
103.31.4.17 ×
103.31.4.18 ×
103.31.4.19 ×
103.31.4.20 ×
103.31.4.21 ×
103.31.4.22 ×
103.31.4.23 ×
141.101.64.1 1587
141.101.64.2 ×
141.101.64.3 ×
141.101.64.4 270
141.101.64.5 257
141.101.64.6 264
141.101.64.7 237
141.101.64.8 268
141.101.64.9 ×
141.101.64.10 ×
141.101.64.11 256
141.101.64.12 264
141.101.64.13 267
141.101.64.14 258
141.101.64.15 253
141.101.64.16 251
141.101.64.17 261
141.101.64.18 255
141.101.64.19 ×
108.162.192.1 156
108.162.192.2 ×
108.162.192.3 168
108.162.192.4 149
108.162.192.5 156
108.162.192.6 169
108.162.192.7 155
108.162.192.8 151
108.162.192.9 162
108.162.192.10 141
108.162.192.11 143
108.162.192.12 153
108.162.192.13 148
108.162.192.14 186
108.162.192.15 155
108.162.192.16 166
108.162.192.17 170
108.162.192.18 165
108.162.192.19 143
190.93.240.1 ×
190.93.240.2 ×
190.93.240.3 ×
190.93.240.4 ×
190.93.240.5 ×
190.93.240.6 ×
190.93.240.7 ×
190.93.240.8 ×
190.93.240.9 ×
190.93.240.10 ×
190.93.240.11 ×
190.93.240.12 ×
190.93.240.13 ×
190.93.240.14 ×
190.93.240.15 ×
190.93.240.16 ×
190.93.240.17 ×
190.93.240.18 ×
190.93.240.19 ×
190.93.240.20 ×
190.93.240.21 ×
188.114.96.1 ×
188.114.96.2 ×
188.114.96.3 ×
188.114.96.4 ×
188.114.96.5 ×
188.114.96.6 ×
188.114.96.7 ×
188.114.96.8 ×
188.114.96.9 ×
188.114.96.10 ×
188.114.96.11 ×
188.114.96.12 ×
188.114.96.13 ×
188.114.96.14 ×
188.114.96.15 ×
188.114.96.16 ×
188.114.96.17 ×
188.114.96.18 ×
188.114.96.19 ×
188.114.96.20 ×
188.114.96.21 ×
197.234.240.1 394
197.234.240.2 451
197.234.240.3 431
197.234.240.4 412
197.234.240.5 459
197.234.240.6 ×
197.234.240.7 ×
197.234.240.8 ×
197.234.240.9 ×
197.234.240.10 ×
197.234.240.11 ×
197.234.240.12 ×
197.234.240.13 ×
197.234.240.14 ×
197.234.240.15 ×
197.234.240.16 ×
197.234.240.17 ×
197.234.240.18 ×
197.234.240.19 ×
197.234.240.20 ×
197.234.240.21 ×
197.234.240.22 ×
197.234.240.23 ×
198.41.128.1 ×
198.41.128.2 ×
198.41.128.3 ×
198.41.128.4 ×
198.41.128.5 ×
198.41.128.6 ×
198.41.128.7 ×
198.41.128.8 ×
198.41.128.9 ×
198.41.128.10 ×
198.41.128.11 ×
198.41.128.12 ×
198.41.128.13 ×
198.41.128.14 ×
198.41.128.15 ×
198.41.128.16 ×
198.41.128.17 ×
198.41.128.18 ×
162.158.0.1 261
162.158.0.2 260
162.158.0.3 319
162.158.0.4 ×
162.158.0.5 ×
162.158.0.6 ×
162.158.0.7 ×
162.158.0.8 ×
162.158.0.9 ×
162.158.0.10 ×
162.158.0.11 ×
162.158.0.12 ×
162.158.0.13 ×
162.158.0.14 ×
162.158.0.15 ×
162.158.0.16 ×
172.64.0.1 168
172.64.0.2 153
172.64.0.3 166
172.64.0.4 160
172.64.0.5 162
172.64.0.6 ×
172.64.0.7 149
172.64.0.8 ×
172.64.0.9 161
172.64.0.10 ×
172.64.0.11 ×
172.64.0.12 164
172.64.0.13 173
172.64.0.14 149
131.0.72.1 ×
131.0.72.2 ×
131.0.72.3 ×
131.0.72.4 ×
131.0.72.5 ×
131.0.72.6 ×
131.0.72.7 ×
131.0.72.8 ×
131.0.72.9 ×
131.0.72.10 ×
131.0.72.11 ×
131.0.72.12 ×
131.0.72.13 ×
131.0.72.14 ×
131.0.72.15 ×
131.0.72.16 ×
131.0.72.17 ×
131.0.72.18 ×
131.0.72.19 ×
131.0.72.20 ×
131.0.72.21 ×
131.0.72.22 ×
131.0.72.23 ×
104.16.0.1 146
104.16.0.2 159
104.16.0.3 149
104.16.0.4 172
104.16.0.5 158
104.16.0.6 154
104.16.0.7 ×
104.16.0.8 ×
104.16.0.9 148
104.16.0.10 147
104.16.0.11 145
104.16.0.12 ×
104.16.0.13 540
104.16.0.14 598
104.24.0.1 154
104.24.0.2 247
104.24.0.3 704
104.24.0.4 291
104.24.0.5 155
104.24.0.6 157
104.24.0.7 683
104.24.0.8 159
104.24.0.9 169
104.24.0.10 177
104.24.0.11 187
104.24.0.12 191
104.24.0.13 148
104.24.0.14 172
104.24.0.15 163
[Finished in 794.4s]

其中,IP地址后的数字为ping延迟时间,单位是ms。打×的是ping不通的,可能是被墙了。

值得一提的是,并不是所有能ping通的IP地址都可用作自选IP,笔者测试了几个,如104.24.0.*108.162.192.*都不可做*2**yN的服务器自选IP。

本文由作者按照 CC BY 4.0 进行授权

© Dignite. 保留部分权利。 由  提供CDN加速。

浙ICP备2023032699号 | 使用 Jekyll 主题 Chirpy