帮助用户搭建 WireGuard VPN、配置客户端并安全远程访问家庭网络。
复制安装指令,让 AI 自动完成配置 · 推荐新手
请帮我安装 askskill 上的 "homelab-wireguard-vpn" 技能: 1. 下载 https://raw.githubusercontent.com/affaan-m/ECC/main/skills/homelab-wireguard-vpn/SKILL.md 2. 保存为 ~/.claude/skills/homelab-wireguard-vpn/SKILL.md 3. 装好后重载技能,告诉我可以用了
请为我的家庭实验室生成一份 WireGuard VPN 服务器搭建指南,包括服务端安装、密钥生成、配置文件示例、防火墙与端口转发设置,系统为 Ubuntu。
一份可执行的 Ubuntu WireGuard 服务器部署说明,含配置示例与网络设置要点。
我已经有 WireGuard 服务端,请帮我分别为 iPhone 和 Windows 笔记本生成 peer 配置示例,包含密钥生成步骤、AllowedIPs 设置和二维码导入说明。
适用于手机和电脑的客户端配置示例,并说明如何安全导入和连接。
请比较 WireGuard 的 full tunnel 和 split tunnel 配置差异,并根据“仅访问家庭 NAS 和内网服务,不影响日常上网”的需求,给出推荐配置和 AllowedIPs 示例。
对两种路由模式的清晰对比,以及适合家庭远程访问场景的推荐配置。
WireGuard is a fast, modern VPN protocol. It is the right choice for remote access to a home network — simpler to configure than OpenVPN and faster than most alternatives.
All configuration examples show common setups. Review each command — especially the iptables forwarding rules and key file permissions — before applying them to your system, and make changes in a maintenance window.
Your phone (WireGuard client)
│
│ Encrypted UDP tunnel (port 51820)
│
Your home router (WireGuard server — needs a public IP or DDNS)
│
Your home network (192.168.1.0/24, NAS, Pi, etc.)
Every device has a keypair (public + private key).
The server knows each client's public key.
The client knows the server's public key + endpoint (IP:port).
Traffic is encrypted end-to-end with no central server or certificate authority.
# Install WireGuard
sudo apt update && sudo apt install wireguard -y
# Generate server keypair — create files with private permissions from the start
sudo mkdir -p /etc/wireguard
sudo sh -c 'umask 077; wg genkey > /etc/wireguard/server_private.key'
sudo sh -c 'wg pubkey < /etc/wireguard/server_private.key > /etc/wireguard/server_public.key'
# Write server config — substitute the actual private key value
# Do not store private keys in version control or share them
sudo tee /etc/wireguard/wg0.conf << 'EOF'
[Interface]
Address = 10.8.0.1/24 # VPN subnet — server gets .1
ListenPort = 51820
PrivateKey = <paste_server_private_key_here>
# Scoped forwarding rules: allow VPN traffic in/out, not a blanket FORWARD ACCEPT
PostUp = iptables -A FORWARD -i wg0 -o eth0 -j ACCEPT
PostUp = iptables -A FORWARD -i eth0 -o wg0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostUp = iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -o eth0 -j ACCEPT
PostDown = iptables -D FORWARD -i eth0 -o wg0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer]
# Phone — replace with the actual phone public key
PublicKey = <phone_public_key>
AllowedIPs = 10.8.0.2/32
[Peer]
# Laptop — replace with the actual laptop public key
PublicKey = <laptop_public_key>
AllowedIPs = 10.8.0.3/32
EOF
sudo chmod 600 /etc/wireguard/wg0.conf
# Replace eth0 with your actual outbound interface name
# Check with: ip route show default
# Enable IP forwarding (required for routing traffic through the server)
echo "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/99-wireguard.conf
sudo sysctl --system
# Start WireGuard and enable on boot
sudo wg-quick up wg0
sudo systemctl enable wg-quick@wg0
# Generate a unique keypair for each client device
# Run on the client, or on the server and transfer the private key securely — never in plaintext
umask 077
wg genkey | tee phone_private.key | wg pubkey > phone_public.key
# Client config file (phone_wg0.conf):
[Interface]
PrivateKey = <phone_private_key>
Address = 10.8.0.2/32
DNS = 192.168.1.2 # Optional: use Pi-hole for DNS over the tunnel
[Peer]
PublicKey = <server_public_key>
Endpoint = your-home-ip.ddns.net:51820 # Your public IP or DDNS hostname
AllowedIPs = 192.168.1.0/24 # Split tunnel: only home network traffic
# AllowedIPs = 0.0.0.0/0, ::/0 # Full tunnel: all traffic through VPN
PersistentKeepalive = 25 # Keep NAT hole open (required for mobile clients)
…
帮助开发者为代码代理配置性能优化、安全防护与研究优先工作流。
提供数据库迁移、回滚与零停机发布的最佳实践指导,适用于多种 ORM 与 SQL 数据库。
通过双评审智能体对结果进行对抗式校验,提升输出发布前的可靠性
帮助你掌握地道 Rust 模式、所有权与并发实践,编写安全高性能应用。
基于 C++ Core Guidelines 编写、审查并重构更安全现代的 C++ 代码。
为 Claude Code 会话提供系统化校验流程,帮助检查结果正确性与质量。
帮助用户配置家庭实验室 WireGuard VPN,实现安全远程访问与密钥管理。
为家庭实验室网络改造提供分段、DNS过滤与远程访问变更前检查清单
帮助你规划家庭与实验室网络拓扑、地址分配、设备连接与常见避坑。
帮助开发与运维团队安全地将本地服务通过加密隧道发布到公网。
帮助用户规划家庭实验室的VLAN分段、访问控制与流量隔离策略。
帮助你部署和维护家庭网络中的 Pi-hole 广告拦截与 DNS 服务