logo NodeSeekbeta

【“桂港专线”】【教程ipv6only】利用socat一键国内鸡转发脚本

别提X-UI 极光面板之类的了,首先你的安装的上,其次你得连的上,CN鸡禁国外流量。

被人喷我只会抄袭,真的烦。参考资料如下:
椰子的文章
清华大学镜像源

我有个朋友,一天到晚骚扰我,如何进行ipv6转发,实现平民法拉利。

关于测速的部分不再赘述了。因为之前我的帖子中有比较过

晚高峰电信可以随便跑300M单线,对我来说作为保底没啥问题,这里以wap.ac超售家的为例。
一年13刀即可体验隧道的感觉(反正原理差不多)

大概说一下转发的原理

服务器A(流量)>交给服务器B(流量)>交给用户。

用户与A并非直连,所有A是否有回国优化无关紧要,只要B跟你的连接好即可。

那么教程开始

一键脚本(为什么不托管github呢?因为我那个吊毛朋友说不知道我在脚本里是否使坏。MJJ的特性。那我就把全部写出来,复制黏贴到自己的vps内即可。

测试环境(debian 10/11) 其他没试,没空试。

我不清楚是否有人写过一样的内容,反正东西是我自己整理写的,测试也通过了,支持多ip添加

全流程>一键安装>添加转发>启动服务(完毕了)
这时候又有吊毛要问了,我要添加多个ip咋办?
答:再复制一边脚本启动,然后直接选择 添加转发>启动服务 (启动服务敲黑板)不管你要添加几次 几个ip,都要再添加完后启动服务。

一键脚本

#!/bin/bash

# 显示主菜单
show_menu() {
    clear
    echo "===================================="
    echo "==欢迎使用maizi制作的socat转发面板=="
    echo "==如遇困难请联系TG:https://t.me/tel_with_maizi_bot=="
    echo "===================================="
    echo "请选择:"
    echo "0. 退出脚本"
    echo "-----------------------------------------------------------------"
    echo "1. 一键部署转发"
    echo "2. 添加转发"
    echo "3. 移除转发(懒得写)"
    echo "4. 查看转发"
    echo "5. 启动服务"
    echo "-----------------------------------------------------------------"
}

handle_error() {
    echo -e "\e[31m发生错误,操作未成功完成。\e[0m"
    exit 1
}

countdown() {
    local SECONDS=3
    echo -e "\e[32m操作成功完成,将在 $SECONDS 秒后返回主菜单...\e[0m"
    while [ $SECONDS -gt 0 ]; do
        echo -n "$SECONDS..."
        sleep 1
        ((SECONDS--))
    done
    echo
}

initialize_socat_start() {
    echo "初始化转发列表文件..."
    > /usr/local/bin/socat-start.sh || handle_error
    chmod +x /usr/local/bin/socat-start.sh || handle_error
}

add_forwarding() {
    # 清除现有的#!/bin/bash和wait
    sed -i '/^#!/d' /usr/local/bin/socat-start.sh
    sed -i '/^wait$/d' /usr/local/bin/socat-start.sh
    while true; do
        read -p "请输入IP地址: " ip
        read -p "请输入端口: " port
        # 添加新的转发规则
        echo "/usr/bin/socat TCP6-LISTEN:${port},fork,reuseaddr TCP6:[${ip}]:${port} &" >> /usr/local/bin/socat-start.sh
        echo "转发规则已添加。"
        read -p "是否继续添加(Y/N)? " answer
        if [[ "$answer" != "Y" && "$answer" != "y" ]]; then
            # 用户完成添加,将#!/bin/bash和wait分别添加到文件的首尾
            sed -i '1i#!/bin/bash' /usr/local/bin/socat-start.sh
            echo "wait" >> /usr/local/bin/socat-start.sh
            chmod +x /usr/local/bin/socat-start.sh || handle_error
            countdown
            break
        fi
    done
}

deploy_socat() {
    echo "更新软件源并安装 socat..."
    cat > /etc/apt/sources.list << EOF || handle_error
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://security.debian.org/debian-security bullseye-security main contrib non-free
EOF
    apt-get update || handle_error
    apt-get install -y socat || handle_error
    initialize_socat_start
    echo "创建并配置socat服务..."
    cat > /etc/systemd/system/socat.service << EOF || handle_error
[Unit]
Description=Internet Freedom

[Service]
DynamicUser=true
ProtectSystem=true
ProtectHome=true
ExecStart=/usr/local/bin/socat-start.sh
Restart=always

[Install]
WantedBy=multi-user.target
EOF
    systemctl daemon-reload || handle_error
    systemctl enable socat.service || handle_error
    echo -e "\e[32m服务已安装完成\e[0m"
    countdown
}

view_forwarding() {
    echo "当前转发规则如下:"
    cat /usr/local/bin/socat-start.sh || handle_error
    read -p "按任意键返回主菜单..."
}

start_service() {
    systemctl daemon-reload || handle_error
    systemctl restart socat.service || handle_error
    echo -e "\e[32msocat服务已启动。\e[0m"
    countdown
}


while true; do
    show_menu
    read -p "请输入您的选择(0-5): " choice
    case $choice in
        0)
            echo "退出脚本。"
            break
            ;;
        1)
            deploy_socat
            ;;
        2)
            add_forwarding
            ;;
        3)
            echo "移除转发(此功能需要您自己实现)。"
            ;;
        4)
            view_forwarding
            ;;
        5)
            start_service
            ;;
        *)
            echo "无效输入,请重新输入。"
            ;;
    esac
done


感谢各位看官。辛苦您的阅读了。

  • @maizi #6
    鏡像地址如下:(清華大學白名單鏡像源)
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free

    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free

    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free

    deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

    deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free

    一般情况下,将 /etc/apt/sources.list 文件中 Debian 默认的源地址 http://deb.debian.org/ 替换为镜像地址即可。(以上全部複製替換)
    reboot命令重啓

    然後使用IPv6代理访问Github(複製下面一鍵命令,執行)
    cat >> /etc/hosts << EOF

    https://danwin1210.de/github-ipv6-proxy.php

    2a01:4f8:c010:d56::2 github.com
    2a01:4f8:c010:d56::3 api.github.com
    2a01:4f8:c010:d56::4 codeload.github.com
    2a01:4f8:c010:d56::5 objects.githubusercontent.com
    2a01:4f8:c010:d56::6 ghcr.io
    2a01:4f8:c010:d56::7 pkg.github.com npm.pkg.github.com maven.pkg.github.com nuget.pkg.github.com rubygems.pkg.github.com
    EOF

    然後就可以裝xui了

  • 不错不错收藏了

  • xhj003

    感覺還是xui任意門方便一些

  • 所以说有推荐的ipv6国内🐔吗

  • 好帖

  • @debian11 #3 很多啊,duoduo,wap。。其他的没关注,反正很多

  • @JackieWynn #2 CN鸡禁止国外流量,x-ui安装不上

  • xui方便

  • @ithk #7 前提是你得安装得上

  • @maizi #6 能裝上的,換鏡像源就行(清華大學源是白名單)

  • @maizi #8 前提我已经在用了 ac01

你好啊,陌生人!

我的朋友,看起来你是新来的,如果想参与到讨论中,点击下面的按钮!

📈用户数目📈

目前论坛共有15411位seeker

🎉欢迎新用户🎉