# OpenWrt WireGuard安裝

#### **安裝套件**

**WEB CLI上安裝以下套件**

```
wireguard-tools
luci-app-wireguard
qrencode
```

#### **新增WireGuard介面**

**10.9.0.1/32 為此介面ip**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-07/scaled-1680-/BGXimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-07/BGXimage.png)

#### **建立防火牆**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-07/scaled-1680-/nlLimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-07/nlLimage.png)

#### **對等端Client*設定***

**客戶端公鑰**

**10.9.0.2/32 客戶端IP**

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-07/scaled-1680-/n1Ximage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-07/n1Ximage.png)

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-07/scaled-1680-/Fpyimage.png)](https://note.homesitetw.com/uploads/images/gallery/2025-07/Fpyimage.png)

```
編輯新增的防火牆設定wg

wireguard介面設定完皆須重新啟動

如果要將所有流量通過vpn上internet，防火牆需新增
iptables -t nat -A POSTROUTING -s 10.9.0.0/24 -o br-lan -j MASQUERADE
重啟防火牆
```

**Windows WireGuard設定**

```
Address wireguard ip
PublicKey server公鑰
AllowedIPs 允許網段通過vpn
Endpoint server ip和port
```

[![image.png](https://note.homesitetw.com/uploads/images/gallery/2025-07/scaled-1680-/Mr3image.png)](https://note.homesitetw.com/uploads/images/gallery/2025-07/Mr3image.png)

<p class="callout info">**MTU自行調整，建議1380**</p>