> For the complete documentation index, see [llms.txt](https://docs.ipwo.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipwo.net/dai-li-ji-chu-zhi-shi/shen-me-shi-gong-wang-ip.md).

# 什么是公网IP

公网 IP（Public IP）是设备连接互联网时，对外显示的 IP 地址。

简单来说：

👉 公网 IP 就是你在互联网中的“网络地址”。

网站、服务器或 API 看到的，通常都是你的公网 IP。

***

### 🌍 公网 IP 的工作原理

当你的设备访问网站时：

```
你的设备
↓
公网 IP
↓
目标网站
```

👉 网站会通过公网 IP 判断你的网络来源。

***

### 📌 公网 IP 长什么样？

例如：

```
123.123.123.123
```

这就是一个公网 IP 示例。

***

### ⚠️ 公网 IP ≠ 本地 IP

很多用户容易混淆：

| 类型    | 示例              |
| ----- | --------------- |
| 公网 IP | 123.123.123.123 |
| 本地 IP | 192.168.x.x     |

***

### ❌ 常见本地 / 内网 IP

以下属于本地 IP：

```
192.168.x.x
10.x.x.x
172.x.x.x
```

👉 这些不能直接在互联网中使用。

***

### 🔍 为什么公网 IP 很重要？

很多服务会根据公网 IP：

* 判断地区
* 限制访问频率
* 配置 [API 白名单](/huo-qu-yu-pei-zhi-dai-li/ip-bai-ming-dan.md)
* 检测网络环境

***

### ⚙️ 代理与公网 IP 的关系

正常情况下：

```
你的公网 IP
↓
目标网站
```

使用代理后：

```
代理公网 IP
↓
目标网站
```

👉 网站看到的将是代理 IP，而不是你的本机公网 IP。

***

### 🌐 如何查看当前公网 IP？

推荐访问：

```
https://ipinfo.io
```

或：

```
https://api.ipify.org
```

***

### ⚡ 命令行查看方式

执行：

```bash
curl ipinfo.io
```

***

#### 返回示例

```
123.123.123.123
```

👉 返回的即为当前公网 IP。

***

### 🔒 什么是 [API 白名单](/huo-qu-yu-pei-zhi-dai-li/ip-bai-ming-dan.md)？

很多 API 服务会限制：

👉 只有指定公网 IP 才能访问。

这就是：

```
IP 白名单
```

***

### ⚠️ 为什么白名单经常失效？

可能原因：

* 当前公网 IP 已变化
* 使用了动态公网 IP
* 添加了错误 IP

***

### 🏠 家庭宽带公网 IP 会变化吗？

部分网络环境：

* 家庭宽带
* 手机热点
* 动态公网网络

公网 IP 可能会变化。

👉 重启网络后 IP 可能不同。

***

### 🌍 使用服务器时需要注意什么？

如果程序运行在：

* [VPS](/huan-jing-zhun-bei/vps-yun-fu-wu-qi-tui-jian.md)
* [云服务器](/huan-jing-zhun-bei/vps-yun-fu-wu-qi-tui-jian.md)
* Docker

👉 API 实际校验的是服务器公网 IP，而不是本地电脑 IP。

***

### 💡 公网 IP 常见用途

公网 IP 常用于：

```
API 白名单
代理验证
网络排查
地区检测
服务器访问控制
```

***

### ❗ 常见问题

#### 为什么网站看到的 IP 和本地 IP 不一样？

因为网站看到的是：

👉 公网 IP，而不是内网 IP。

***

#### 为什么使用代理后 IP 变了？

因为请求经过了代理服务器。

👉 网站看到的是代理公网 IP。

***

#### 为什么每次查看公网 IP 都不同？

可能使用的是：

👉 动态公网 IP 网络。

***

### 🆘 遇到问题怎么办？

如果出现：

* [白名单不生效](/gu-zhang-pai-chu/bai-ming-dan-bu-sheng-xiao.md)
* [API 无法访问](/gu-zhang-pai-chu/api-fan-hui-wei-kong.md)
* IP 不正确

建议优先检查：

* 当前公网 IP
* 网络环境
* 是否使用代理

***

### 总结

公网 IP 的核心作用：

```
设备访问互联网
↓
显示公网 IP
↓
网站识别网络来源
```

👉 公网 IP 是[代理](/dai-li-ji-chu-zhi-shi/shen-me-shi-dai-li-ip.md)、[白名单](/huo-qu-yu-pei-zhi-dai-li/ip-bai-ming-dan.md)与网络访问中的核心基础概念

***


---

# 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:

```
GET https://docs.ipwo.net/dai-li-ji-chu-zhi-shi/shen-me-shi-gong-wang-ip.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.
