创建一个自己的 IPv6 代理池 (ndppd + openresty)

创建一个自己的 IPv6 代理池 (ndppd + openresty)

Post Views: 2,632原创文章,转载请注明出处https://qiedd.com/

0x00 简介抓某站时遇到了被 IP 限流问题,但是某站没有对 v6 的限制,v6 only 的服务器很好买,而且便宜。

一开始使用 https://github.com/zu1k/http-proxy-ipv6-pool 发现高并发的场景下经常报错,因此找到了另一个方案 https://blog.yllhwa.com/2022/09/05/利用IPV6绕过B站的反爬/ ,

结合两个方案的优点,可以在不绑定网卡下使用 v6,并且在高并发的情况下也不会报错,故此写下本 blog

0x01 IPv6如果你本机没有 v6,可以去 he 申请一段 v6, 地址:https://tunnelbroker.net/

具体怎么申请不过多赘述,google 一下随便有

0x02 安装依赖debian 从官方源安装 openresty 请看此 blog:https://blog.openresty.com/en/openresty-pre-built-for-debian-11/

# 安装 openresty

sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates

wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -

codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release`

echo "deb http://openresty.org/package/debian $codename openresty" \

| sudo tee /etc/apt/sources.list.d/openresty.list

sudo apt-get update

sudo apt-get -y install openresty

#安装 ndppd

apt install ndppd -y

# 内核,以及一些优化参数

vim /etc/sysctl.conf

fs.inotify.max_user_watches = 524288

net.ipv6.conf.all.proxy_ndp=1

net.ipv6.conf.default.forwarding=1

net.ipv6.conf.all.forwarding=1

net.ipv6.ip_nonlocal_bind=1

net.ipv4.ip_local_port_range=1024 64000

net.ipv6.route.max_size=409600

net.ipv4.tcp_max_syn_backlog=4096

net.ipv6.neigh.default.gc_thresh3=102400

kernel.threads-max=1200000

vm.max_map_count=6000000

kernel.pid_max=2000000

net.core.default_qdisc = cake

net.ipv4.tcp_congestion_control = bbr

net.ipv4.tcp_fastopen = 3

# 应用

sysctl -p0x03 ndppd 配置# 先添加一条路由

## 网卡需要对应的网卡,我这里是 eth0,其他系统可能是 ens0

## 如果你用的是 he,并且没有修改 he 给你的配置,这里的网卡是 he-ipv6,不用加 @ 后面的东西

## 如果你用的是 he,这里是 Routed IPv6 Prefixes, 而不是 Client IPv6 Address:

ip route add local 2001:1:1:1::/64 dev eth0

# 修改配置

vim /etc/ndppd.conf

## 同样的,如果你这里是其他网卡,请修改 eth0

## 同样的,如果使用的是 he,这里是 Routed IPv6 Prefixes, 而不是 Client IPv6 Address:

route-ttl 30000

proxy eth0 {

router no

timeout 500

ttl 30000

rule 2001:1:1:1::/64 {

static

}

}

# ndppd, 启动!

systemctl enable ndppd

systemctl start ndppd

# 在你的 v6 网段下随便找个地址测试

## 返回 2001:1:1:1::1145 则是正常

curl --interface 2001:1:1:1::1145 ip.sb0x04 openresty 配置如果你的跟着我配置的,那么 openresty 的配置在如下目录 /usr/local/openresty/nginx/conf/

# 进入目录

cd /usr/local/openresty/nginx/conf/

# 配置 nginx.conf

## 需要删除现有的 server,添加其他一个应用的目录,我会把我的配置完整的展示出来

vim nginx.conf

# 创建一个目录

mkdir conf.d && cd conf.d

# 创建一个文件

## 需要改成自己的 bind_ip

vim bili-proxy

# openresty, 启动!

systemctl enable openresty

systemctl restart openresty

# 测试

curl 127.0.0.1:33333/x/web-interface/zonenginx.confworker_processes 1;

events {

worker_connections 1024;

}

http {

include mime.types;

include conf.d/*;

default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

#gzip on;

}bili-proxy

upstream bili_cdn_ipv6 {

server [240e:cf:9000:2::9d]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:cf:9000:2::9a]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:cf:9000:2::99]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:f7:e01f:f1::31]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:f7:e01f:f1::30]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::74]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::77]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::76]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::70]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::78]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:968:7001:120::73]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:968:7001:120::72]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:968:7001:120::71]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::85]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:978:90d:1000::86]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:f7:e01f:f1::28]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:f7:e01f:f1::29]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:f7:e01f:f1::27]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:10:1402:0:1:1:39]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:10:1402:0:1:1:38]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:10:1402:0:1:1:40]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:10:1402:0:1:1:41]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:2000:c0e::31]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:2000:c0e::33]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:2000:c0e::32]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:97d:2000:c0e::34]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:930:c200:209::45]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:930:c200:209::46]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:930:c200:209::35]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:930:c200:209::34]:443 max_fails=2 fail_timeout=10s weight=1;

server [240e:930:c200:209::36]:443 max_fails=2 fail_timeout=10s weight=1;

}

server {

listen 33333;

server_name localhost;

access_log off;

location / {

set_by_lua_block $bind_ip {

return '2001:1:1:1' .. string.format(':%x', math.random(1, 65535)) .. string.format(':%x', math.random(1, 65535)) .. string.format(':%x', math.random(1, 65535)) .. string.format(':%x', math.random(1, 65535))

}

proxy_bind $bind_ip;

proxy_pass https://bili_cdn_ipv6;

proxy_set_header Host api.bilibili.com;

}

}

server {

listen 33334;

server_name localhost;

access_log off;

location / {

set_by_lua_block $bind_ip {

return '2001:1:1:1' .. string.format(':%x', math.random(1, 65535)) .. string.format(':%x', math.random(1, 65535)) .. string.format(':%x', math.random(1, 65535)) .. string.format(':%x', math.random(1, 65535))

}

proxy_bind $bind_ip;

proxy_pass https://bili_cdn_ipv6;

proxy_set_header Host app.bilibili.com;

}

}

相关推荐

港股阿里系之:借壳5年终入正轨的阿里健康(241.HK)
365bet网球比赛比分

港股阿里系之:借壳5年终入正轨的阿里健康(241.HK)

📅 09-26 👁️ 5878
哪个版本的禅道项目管理软件最适合中小企业?
安卓软件下SH365

哪个版本的禅道项目管理软件最适合中小企业?

📅 11-15 👁️ 4200
没有找到站点
365bet网球比赛比分

没有找到站点

📅 11-16 👁️ 9239
曲字开头的成语有哪些
365sport365

曲字开头的成语有哪些

📅 11-16 👁️ 3473
艺术照风格详解
365bet网球比赛比分

艺术照风格详解

📅 07-08 👁️ 7273
极速28在线开奖|极速28最新50期开奖结果|极速28历史开奖记录统计查询
怎么养宠物螃蟹(注意事项)
365sport365

怎么养宠物螃蟹(注意事项)

📅 10-04 👁️ 5282
辐射4维吉尔的血清获得位置及不同选择的各种结果
365bet网球比赛比分

辐射4维吉尔的血清获得位置及不同选择的各种结果

📅 11-26 👁️ 5628
裤子掉色怎么办 裤子掉色怎么处理
365sport365

裤子掉色怎么办 裤子掉色怎么处理

📅 07-12 👁️ 1589