> For the complete documentation index, see [llms.txt](https://beej.netdpi.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://beej.netdpi.net/ipaddress_struct/ip_set/private-network.md).

# 3.4.1 Private Network

很多地方都有防火牆（firewall），它們保護網路，將網路隱藏於世界的某個地方。有時，防火牆會用所謂的網路位址轉換（NAT，Network Address Translation）的方法，將 "internal"（內部的）IP 位址轉換為 "external"（外部的）［世界上的每個人都知道的］IP address。

你又開始緊張了嗎？＂他又要扯到哪裡去了？＂

好啦，放輕鬆，去買瓶汽水［或酒精］飲料，因為身為一個初學者，你還可以先別理 NAT，因為它所做的事情對你而言是透明的。不過我想在你開始對所見的網路數量開始感到困惑以前，先談談防火牆後面的網路。

比如，我家有一個防火牆，我有兩個 DSL 電信公司分配給我的靜態 IPv4 位址，而我家的網路有七部電腦要用。這有可能嗎？兩台電腦不能共用同一個 IP address 阿，不然資料就不知道該送去哪一台電腦了！

答案揭曉：它們不會共用同一個 IP address，它們是在一個擁有兩千四百萬個 IP address 的 private network 裡面，這些 IP addresses 全部都是我的。

好，都是你的，有這麼多位址可以讓大家用來上網，而這裡要講的就是為什麼：

如果我登入到一台遠端的電腦，它會說我從 192.0.2.33 登入，這是我的 ISP 提供給我的 public IP。不過若是我問我自己本地端的電腦，它的 IP address 是什麼時，他會說是 10.0.0.5。是誰轉換 IP 的呢？答對了，就是防火牆！它做了 NAT！

10.x.x.x 是其中一個少數保留的網路，只能用在完全無法連上 Internet 的網路［disconnected network］，或是在防火牆後的網路。你可以使用哪個 private network 編號的細節是記在 RFC 1918 \[15] 中，不過一般而言，你較常見的是 10.x.x.x 及 192.168.x.x，這裡的 x 是指 0-255。較少見的是 172.y.x.x，這裡的 y 範圍在 16 與 31 之間。

在 NAT 防火牆後的網路可以不必用這些保留的網路，不過它們通常會用。

［真好玩！我的外部 IP 真的不是 192.0.2.33，192.0.2.x 網段保留用來虛構本文要用的 ＂真實＂IP address，就像本文也是虛構的一樣 Wowzers！］

IPv6 也很合理的會有 private network。它們是以 fdxx: 開頭［或者未來可能是 fcXX：］，如同 RFC 4193 \[16]。NAT 與 IPv6 通常不會混用，然而［除非你在做 IPv6 轉 IPv4 的 gateway，這就不在本文的討論範圍內了］，理論上，你會有很多位址可以使用，所以根本不再需要使用 NAT。不過，如果你想要在不會遶送到外面的網路［封閉網路］上配置位址給你自己，就用 NAT 吧。

\[15] <http://tools.ietf.org/html/rfc1918>

\[16] <http://tools.ietf.org/html/rfc4193>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://beej.netdpi.net/ipaddress_struct/ip_set/private-network.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
