# 配置服務器防火牆

用防火牆保護遊戲服務器時，爲了正常執行ProudNet，需要考慮以下事項。

> * 服務器運行時 (<mark style="color:orange;">Proud.CNetServer.Start</mark>) <mark style="color:orange;">Proud.CStartServerParameter.m\_tcpPort</mark> 指定的 UDP port(<mark style="color:orange;">Proud.CStartServerParameter.m\_udpPorts</mark>) 發送/接收都必須打開。
> * 如果不是必要的情況，應允許發送和接收ICMP類型的IP分組，這樣才能防止偶爾發生的網絡故障。

## 配置防火牆以應對DDOS攻擊

在ProudNet中，如果與客戶端連接，服務器在UDP通信之前首先向客戶端投擲1個隨機分組。 然後那個客戶端收到那個數據包後直接扔掉。

有些服務器防火牆具有先向網址爲A的客戶端發射UDP數據包，然後允許A在一定時間內接收A向服務器發送UDP數據包的功能。 打開該功能時，得益於ProudNet的上述特徵，在打開UDP的同時，還可以設置對DDOS攻擊安全的防火牆。

如果是這種功能的防火牆，只能通過設置<mark style="color:orange;">Proud.ServerUdpAssignMode\_PerClient</mark>和空置的<mark style="color:orange;">Proud.CStartServerParameter.m\_udpPorts</mark>來運行服務器，並且具有通過最小化同時訪問者限制來運行服務器的優點。

{% hint style="success" %}
**參考**

[**如何使用服務器的UDP端口**](/proudnet.cn/proudnet/usage_pn/tips.md#udp)
{% endhint %}

## 設置 ICMP 防火牆

在服務器啓動選項中使用<mark style="color:orange;">Proud.ServerUdpAssignMode.ServerUdpAssignMode\_Static</mark>時，建議切斷<mark style="color:orange;">ICMP host unreachable</mark>分組的接收。

以下是關於如何使用Windows防火牆的示例。

<figure><img src="/files/1kiPftHzCenRMjhGayj4" alt=""><figcaption><p>防火牆配置示例</p></figcaption></figure>

<figure><img src="/files/0fwcJ4kCp1asoryViQvU" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/tpN83c9KsydTNyKK6OB1" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/DFNLvBZSOYfAvGhGbGXq" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/H9hPQO8QvvOQVBPRo4MC" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/8cyRhf39kjmTwUOpTc9P" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/KaPJci2VvJbSxKm2jLA2" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/kvHCVLnOOXEaFHtBvCQO" alt=""><figcaption></figcaption></figure>

從那以後，直到"結束"出來爲止，一直按"下一個"按鈕就可以了。

{% hint style="success" %}
**參考**

[**如何使用服務器的UDP端口**](/proudnet.cn/proudnet/usage_pn/tips.md#udp)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.proudnet.com/proudnet.cn/proudnet-note/notes/setting_firewall.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
