{"id":28828994,"url":"https://github.com/help660vip/setup-wireguard","last_synced_at":"2025-10-28T13:37:36.696Z","repository":{"id":276655232,"uuid":"929879262","full_name":"help660vip/setup-wireguard","owner":"help660vip","description":"本项目通过一键脚本部署 WireGuard，自动生成服务端及多客户端配置，支持多系统平台，帮助用户快速组建虚拟局域网，适用于内网通信、远程管理等场景。","archived":false,"fork":false,"pushed_at":"2025-05-18T04:58:46.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-18T05:43:30.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://xyz0.242244.xyz","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/help660vip.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-09T16:07:36.000Z","updated_at":"2025-05-18T05:06:06.000Z","dependencies_parsed_at":"2025-05-18T16:01:52.707Z","dependency_job_id":null,"html_url":"https://github.com/help660vip/setup-wireguard","commit_stats":null,"previous_names":["help660vip/wireguard","help660vip/setup-wireguard"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/help660vip/setup-wireguard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/help660vip%2Fsetup-wireguard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/help660vip%2Fsetup-wireguard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/help660vip%2Fsetup-wireguard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/help660vip%2Fsetup-wireguard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/help660vip","download_url":"https://codeload.github.com/help660vip/setup-wireguard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/help660vip%2Fsetup-wireguard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260690942,"owners_count":23047104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-19T05:11:17.815Z","updated_at":"2025-10-28T13:37:36.691Z","avatar_url":"https://github.com/help660vip.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WireGuard 自动安装与客户端配置脚本\n\n本项目提供一键安装和配置 WireGuard 服务端及批量生成客户端配置的 Bash 脚本，适用于 Debian/Ubuntu、CentOS/RHEL/Fedora 系统。脚本可自动完成系统设置、软件安装、密钥生成、配置文件编写和服务启动等操作，大幅简化部署流程。\n\n## 功能特性\n\n* ​**自动化安装**​：检测系统发行版并调用对应包管理器（apt、dnf、yum）安装 WireGuard 及相关工具\n* ​**系统配置**​：\n  * 设置 DNS（默认为 223.5.5.5）\n  * 启用 IPv4 转发\n  * 备份原有 `/etc/resolv.conf`\n* ​**密钥管理**​：自动生成服务器端和客户端的密钥对及预共享密钥（PSK）\n* ​**配置生成**​：\n  * 创建服务端配置（`/etc/wireguard/\u003ciface\u003e.conf`）\n  * 批量生成客户端配置文件（`./wireguard_clients/clientX.conf`）\n  * 自动添加 Peer 节点到服务端配置\n* ​**网络设置**​：自动检测默认出口网卡并配置 iptables 转发与 NAT\n* ​**服务管理**​：启动 WireGuard，并将 `wg-quick@\u003ciface\u003e` 服务设置为开机自启\n\n## 环境要求\n\n* ​**操作系统**​：\n  * Debian 10+ / Ubuntu 18.04+\n  * CentOS 7+ / RHEL 7+ / Fedora\n* ​**权限**​：需以 `root` 用户或具备 `sudo` 权限执行脚本\n* ​**依赖工具**​：\n  * `bash`, `wg`, `iptables`, `iproute2`（或 `iproute`）\n  * `curl`, `qrencode`, `resolvconf`\n\n## 使用说明\n\n1. ​**下载脚本**​：\n   ```bash\n   wget https://raw.githubusercontent.com/help660vip/wireguard/main/setup-wireguard.sh\n   ```\n2. ​**赋予执行权限**​：\n   ```bash\n   chmod +x setup_wireguard.sh\n   ```\n3. ​**运行脚本**​：\n   ```bash\n   sudo ./setup_wireguard.sh\n   ```\n4. ​**交互选项说明**​：\n   * ​**WireGuard 接口名称**​：默认 `wg0`\n   * ​**监听端口**​：默认 `51820`\n   * ​**客户端数量**​：默认生成 1 个\n   * ​**Endpoint 配置**​：可选择自动检测公网 IP 或手动输入域名/IP\n5. ​**生成结果**​：\n   * 服务端配置：`/etc/wireguard/\u003ciface\u003e.conf`\n   * 客户端配置：`./wireguard_clients/client1.conf`、`client2.conf`…\n\n## 示例\n\n```bash\n# 使用默认参数，一键部署\nsudo ./setup_wireguard.sh\n\n# 自定义接口名和客户端数量\nsudo WG_IF=wg1 COUNT=3 ./setup_wireguard.sh\n```\n\n## 脚本参数（可选环境变量）\n\n| 变量名            | 含义               | 默认值               |\n| ------------------- | -------------------- | ---------------------- |\n| WG\\_IF            | WireGuard 接口名称 | wg0                  |\n| WG\\_PORT          | WireGuard 监听端口 | 51820                |\n| WG\\_NETWORK       | WireGuard 子网网段 | 10.2.0.0/24          |\n| WG\\_SERVER\\_IP    | 服务端分配地址     | 10.2.0.1             |\n| WG\\_CONF\\_DIR     | 服务端配置文件目录 | /etc/wireguard       |\n| CLIENT\\_CONF\\_DIR | 客户端配置输出目录 | ./wireguard\\_clients |\n\n## 常见问题\n\n* ​**无法获取公网 IP**​：脚本会提示手动输入 Endpoint\n* ​**防火墙阻止 UDP**​：请确保服务器防火墙（如 `firewalld`、`ufw`）已放行 WireGuard 监听端口\n* ​**IPv4 转发未生效**​：可手动检查 `/proc/sys/net/ipv4/ip_forward` 值，确认为 `1`\n\n## 许可证\n\n本项目遵循 MIT 许可证\n\n---\n\n\u003e 若有问题或改进建议，欢迎提交 Issues 或 Pull Requests！\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelp660vip%2Fsetup-wireguard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelp660vip%2Fsetup-wireguard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelp660vip%2Fsetup-wireguard/lists"}