Skip to content

Commit 3a2bb2d

Browse files
Auto-update blog content
1 parent da3bd9a commit 3a2bb2d

File tree

65 files changed

+26645
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+26645
-0
lines changed

content/posts/2025-10-31-153420756.md

Lines changed: 573 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
layout: post
3+
title: "公网ip与内网ip"
4+
date: 2025-11-02T19:12:05+0800
5+
description: "浏览器显示的是,cmd的ipconfig显示的是。"
6+
keywords: "公网ip与内网ip"
7+
categories: ['未分类']
8+
tags: ['网络', 'Tcp']
9+
artid: "154300711"
10+
arturl: "https://blog.csdn.net/yan_lai/article/details/154300711"
11+
image:
12+
path: https://api.vvhan.com/api/bing?rand=sj&artid=154300711
13+
alt: "公网ip与内网ip"
14+
render_with_liquid: false
15+
featuredImage: https://bing.ee123.net/img/rand?artid=154300711
16+
featuredImagePreview: https://bing.ee123.net/img/rand?artid=154300711
17+
cover: https://bing.ee123.net/img/rand?artid=154300711
18+
img: https://bing.ee123.net/img/rand?artid=154300711
19+
---
20+
21+
22+
23+
# 公网ip与内网ip
24+
25+
浏览器显示的是**公网 IP**,cmd 的 ipconfig 显示的是**内网 IP**
26+
27+
#### 核心原因:IP 的 “内外分工”
28+
29+
1. 内网 IP 是路由器分配给设备的 “内部地址”,仅在家庭、公司等局域网内使用,无法直接访问互联网。
30+
2. 公网 IP 是运营商分配给路由器的 “公共地址”,是设备连接互联网的唯一标识,用于和外部网络通信。
31+
3. 路由器会通过 “NAT 转换” 技术,让局域网内所有设备共享一个公网 IP 访问互联网,因此两者必然不同。
32+
33+
---
34+
35+
#### 补充说明
36+
37+
* 内网 IP 通常以 192.168.x.x、10.x.x.x、172.16.x.x-172.31.x.x 开头,是私有地址段。
38+
* 公网 IP 是全球唯一的,可通过它定位设备的大致网络位置(如城市)。
39+
* 部分宽带可能使用 “共享公网 IP”,此时浏览器显示的可能是运营商网关的 IP,而非路由器专属公网 IP,但仍与内网 IP 不同。
40+
41+
## 内网 IP 与公网 IP 详细区别对照表
42+
43+
| 对比维度 | 内网 IP(私有 IP) | 公网 IP(公有 IP) |
44+
| --- | --- | --- |
45+
| **核心定义** | 路由器分配给局域网内设备的专属地址 | 运营商分配给网络设备(如路由器)的公共地址 |
46+
| **分配主体** | 路由器(局域网网关) | 互联网服务提供商(ISP) |
47+
| **地址范围** | 192.168.x.x、10.x.x.x、172.16.x.x-172.31.x.x | 除私有地址段外的所有 IPv4/IPv6 地址,全球唯一 |
48+
| **使用范围** | 仅局域网内(家庭、公司等小网络) | 互联网全局范围 |
49+
| **访问功能** | 仅能访问局域网内设备,无法直接被外网访问 | 可与全球互联网设备通信,支持外网主动访问 |
50+
| **重复特性** | 不同局域网内可重复使用(如两个家庭都有 192.168.1.100) | 全球范围内不可重复,是设备的互联网唯一标识 |
51+
| **获取方式** | 设备开机后由路由器自动分配(DHCP 协议) | 宽带拨号时自动获取,部分为固定分配(静态公网 IP) |
52+
| **定位能力** | 无法定位具体设备位置 | 可定位设备所在城市、运营商等大致网络位置 |
53+
| **NAT 转换依赖** | 需通过路由器 NAT 转换,借助公网 IP 访问互联网 | 无需 NAT 转换,直接接入互联网 |
54+
55+
以下是快速判断自身 IP 类型的实操步骤:
56+
57+
* **查看 IP 地址范围**:通过`ipconfig`命令(Windows 系统)或`ifconfig``ip a`命令(Linux/macOS 系统)查看本机 IP 地址。如果 IP 地址属于 10.0.0.0-10.255.255.255、172.16.0.0-172.31.255.255 或 192.168.0.0-192.168.255.255 范围内,则为内网 IP,否则可能是公网 IP。
58+
* **使用在线 IP 查询工具**:打开任意一个常用的 IP 查询网站,如[https://www.ipinfo.io/](https://www.ipinfo.io/ "https://www.ipinfo.io/")[https://www.iplocation.net/](https://www.iplocation.net/ "https://www.iplocation.net/")等,网站会自动显示当前的公共 IP 地址。将此地址与通过命令查看的本机 IP 地址进行对比,如果不一致,那么设备使用的是内网 IP。
59+
* **查看路由器设置**:登录路由器管理界面,找到 WAN 口(广域网)的 IP 地址。如果 WAN 口 IP 地址是公网 IP 范围,则说明路由器使用了 NAT 技术,将内网 IP 地址映射到公网 IP 地址,此时设备处于内网环境。
60+
* **进行网络连通性测试**:从外部网络,如使用手机的 4G 网络,尝试访问该 IP 的某个端口。可以使用`telnet <IP> <端口号>`命令(或`curl/nmap`等工具),如果能够连通,则该 IP 为公网 IP,若无法连通,则可能是内网 IP。
61+
62+
63+
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
---
2+
layout: post
3+
title: "vim的跳转看头文件与分屏"
4+
date: 2025-11-03T17:10:21+0800
5+
description: "看看效果,屏幕利用率会高很多。"
6+
keywords: "vim的跳转看头文件与分屏"
7+
categories: ['未分类']
8+
tags: ['编辑器', 'Vim', 'Linux']
9+
artid: "154353973"
10+
arturl: "https://blog.csdn.net/ikarusuraki/article/details/154353973"
11+
image:
12+
path: https://api.vvhan.com/api/bing?rand=sj&artid=154353973
13+
alt: "vim的跳转看头文件与分屏"
14+
render_with_liquid: false
15+
featuredImage: https://bing.ee123.net/img/rand?artid=154353973
16+
featuredImagePreview: https://bing.ee123.net/img/rand?artid=154353973
17+
cover: https://bing.ee123.net/img/rand?artid=154353973
18+
img: https://bing.ee123.net/img/rand?artid=154353973
19+
---
20+
21+
22+
23+
# vim的跳转看头文件与分屏
24+
25+
![](https://i-operation.csdnimg.cn/images/cf31225e169b4512917b2e77694eb0a2.png)-1
26+
27+
在vim里有几个快速查看头文件的方法:
28+
29+
**最快的方法 - `gf` 命令:**
30+
31+
```
32+
33+
1. 把光标移到头文件路径上(比如 "kernel/types.h")
34+
2. 按 gf (go to file)
35+
3. 看完按 Ctrl-o 返回原文件
36+
37+
```
38+
39+
**分屏查看 - 同时看多个文件:**
40+
41+
```
42+
43+
光标放在头文件路径上
44+
按 Ctrl-w f (在新窗口打开)
45+
Ctrl-w w (切换窗口)
46+
:q (关闭当前窗口)
47+
48+
```
49+
50+
**直接打开:**
51+
52+
```
53+
54+
:e kernel/types.h (打开types.h)
55+
:e user/user.h (打开user.h)
56+
:bp (返回上一个文件)
57+
58+
```
59+
60+
**推荐用 `gf`**,最方便。现在可以:
61+
62+
1. 光标移到第14行的 `"kernel/types.h"`
63+
2.`gf`
64+
3. 看完按 `Ctrl-o` 回来
65+
66+
---
67+
68+
**左右分屏(垂直分割)更适合看代码**
69+
70+
**左右分屏的方法:**
71+
72+
```
73+
74+
# 方法1: 先分屏再打开文件
75+
Ctrl-w v # 垂直分屏(左右分屏)
76+
:e kernel/types.h # 在右侧打开文件
77+
78+
# 方法2: 直接分屏打开
79+
:vsplit kernel/types.h # 或简写 :vsp kernel/types.h
80+
81+
# 方法3: 光标在头文件路径上
82+
Ctrl-w v # 先左右分屏
83+
gf # 再打开光标下的文件
84+
85+
```
86+
87+
**窗口操作:**
88+
89+
```
90+
91+
Ctrl-w w # 在窗口间切换
92+
Ctrl-w h/l # 跳到左/右窗口
93+
Ctrl-w = # 平分窗口大小
94+
Ctrl-w | # 最大化当前窗口宽度
95+
:q # 关闭当前窗口
96+
97+
```
98+
99+
**推荐工作流程:**
100+
101+
```
102+
103+
:vsp kernel/types.h # 左边cat.c,右边types.h
104+
:vsp user/user.h # 再开一个看user.h
105+
Ctrl-w h/l # 左右切换查看
106+
107+
```
108+
109+
试试用 `:vsp kernel/types.h` 看看效果,屏幕利用率会高很多。
110+
111+
112+

0 commit comments

Comments
 (0)