25061202
This commit is contained in:
18
wirguard/wireguard.md
Normal file
18
wirguard/wireguard.md
Normal file
@ -0,0 +1,18 @@
|
||||
# wireguard (内网穿透)
|
||||
|
||||
隧道本身使用 UDP 协议,电信营运商有可能有 QoS 限流或阻断,导致丢包和延迟
|
||||
|
||||
## openwrt
|
||||
|
||||
必须 : kmod-wireguard, wireguard-tools, luci-proto-wireguard
|
||||
可选 : qrencode (生成二维码)
|
||||
|
||||
安装后重启 openwrt
|
||||
|
||||
1. 创建接口,协议 wireguard vpn
|
||||
编辑接口,配置公私钥、配置监听端口、配置隧道的 IP 以及防火墙(防火墙也可以后面单独配置)。公私钥如果已经持有直接填写即可,如果没有可以点击 生成新的密钥对 快速创建。
|
||||
2. 加入防火墙区域 (没有可创建)
|
||||
如果需要局域网内设备普通情况下可以直接和隧道内设备通讯,则需要满足 lan 和 WireGuard 的接口绑定在同一个区域。
|
||||
如果需要隧道内设备可以和局域网内设备通讯,则需要满足 WireGuard 的接口放行了向 lan 或 OpenWrt(即不指定) 的转发
|
||||
3. 配置对端
|
||||
若要对端可以访问本端所在局域网,
|
13
wirguard/拓扑.md
Normal file
13
wirguard/拓扑.md
Normal file
@ -0,0 +1,13 @@
|
||||
# 拓扑
|
||||
|
||||
主要有 4 种拓扑
|
||||
|
||||
1. 点到点 (point to point)
|
||||
2. 中心节点和边缘节点 / 星型 (hub and spoke)
|
||||
3. 点到站 (point to site)
|
||||
4. 站到站 (site to site)
|
||||
|
||||
WireGuard 没有严格的 server 和 client 的角色区分 ,对端 (peer) 既可以是服务器也可以是客户端 。
|
||||
|
||||
## 点到点
|
||||
|
42
wirguard/转发.md
Normal file
42
wirguard/转发.md
Normal file
@ -0,0 +1,42 @@
|
||||
# 转发(forwarding) WireGuard 连接
|
||||
|
||||
## Windows
|
||||
|
||||
1. 中心节点转发 (hub forwarding)
|
||||
2. 站点网关 (site gateway)
|
||||
3. 点到站伪装 (point to site masquerading)
|
||||
4. 点到站端口转发 (point to site forwarding)
|
||||
|
||||
## 中心节点转发
|
||||
|
||||
查看 Windows 网络接口的转发状态,PowerShell 下执行如下指令:
|
||||
|
||||
```code
|
||||
PS> Get-NetIPInterface | Select IfIndex,InterfaceAlias,AddressFamily,ConnectionState,Forwarding | Sort-Object -Property IfIndex | Format-Table
|
||||
```
|
||||
|
||||
以网络接口名称 wg0 为例,启用转发命令如下,这个指令同时启用 IPV4 和 IPV6 转发:
|
||||
|
||||
```code
|
||||
PS> Set-NetIPInterface -InterfaceAlias wg0 -Forwarding Enabled
|
||||
```
|
||||
|
||||
也可以用如下指令单独启用转发:
|
||||
|
||||
```code
|
||||
> netsh interface ipv4 set interface wg0 forwarding=enabled
|
||||
> netsh interface ipv6 set interface wg0 forwarding=enabled
|
||||
```
|
||||
|
||||
对等的 linux 指令如下:
|
||||
|
||||
```code
|
||||
# sysctl -w net.ipv4.conf.wg0.forwarding=1
|
||||
# sysctl -w net.ipv6.conf.wg0.forwarding=1
|
||||
```
|
||||
|
||||
## 站点网关
|
||||
|
||||
启用 WireGuard 站点网关的包转发比中心节点稍微复杂一点,除了 WireGuard 接口 (wg0) 外,还需要启用站点对应的网络适配器接口 (通常为 Ethernet)
|
||||
|
||||
此外,还需要更新局域网路由器的路由表,用于将内网其他终端路由到 WireGuard 主机上
|
Reference in New Issue
Block a user