Skip to content

Commit c595ad8

Browse files
committed
Merge into current branch
1 parent 3ad5e62 commit c595ad8

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

docs/Ch01/supplement.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,62 @@ $ sudo resize2fs /dev/sda2
189189

190190
如果有过分区经验,也可以安装图形化的 GParted 工具进行操作。
191191

192+
### 虚拟机网卡的“模式” {#vm-nic-modes}
193+
194+
在虚拟机中使用网络设备时,会发现虚拟机一般有三种网卡模式,分别叫做 `Bridged`(桥接)、`NAT`(网络地址转换)、`Host only`(仅主机)。虚拟机中的网络设备,是虚拟网卡(Virtual NIC),其背后需要与某个网络连接,才能实现通信功能。
195+
196+
在安装虚拟机前,设备上的网络通常是这样的:
197+
198+
```mermaid
199+
flowchart TD
200+
HSP[主机上的程序] --> HS
201+
HS[主机] -->|物理网卡 10.1.2.3| IN[外部网络]
202+
```
203+
204+
#### 桥接模式 {#bridge-mode}
205+
206+
在这种模式下,虚拟机程序(例如 VMWare)会在主机上创建一个虚拟交换机。虚拟交换机上,接入了原来的物理网卡(例如有线网卡或者 Wi-Fi 适配器等)、虚拟机中安装的虚拟网卡、主机上的虚拟网卡。在这种配置下,虚拟机和主机都暴露在外部网络下,分别使用**不同的 IP**
207+
208+
```mermaid
209+
flowchart TD
210+
VMP1[虚拟机上的程序] --> VM1
211+
VMP2[虚拟机上的程序] --> VM2
212+
HSP[主机上的程序] --> HS
213+
VM1[虚拟机] -->|虚拟网卡 10.1.2.4| SW[虚拟交换机]
214+
VM2[虚拟机] -->|虚拟网卡 10.1.2.5| SW[虚拟交换机]
215+
HS[主机] -->|虚拟网卡 10.1.2.3| SW[虚拟交换机]
216+
SW -->|物理网卡 10.1.2.3/4/5| IN[外部网络]
217+
```
218+
219+
#### 网络地址转换模式 {#nat-mode}
220+
221+
与桥接模式不同,网络地址转换下,虚拟机和主机**共用一个 IP**,虚拟机之间用虚拟交换机连接。从外部网络看来,虚拟机上的程序和主机上的程序发出的请求是一样的。
222+
223+
```mermaid
224+
flowchart TD
225+
VM1[虚拟机] -->|虚拟网卡 192.168.100.100| SW[虚拟交换机 192.168.1.x]
226+
VM2[虚拟机] -->|虚拟网卡 192.168.100.101| SW
227+
SW -->|192.168.1.x| NAT[NAT 网络地址转换]
228+
NAT -->|10.1.2.3| HS
229+
HSP[主机上的程序] -->|10.1.2.3| HS
230+
HSP -->|虚拟网卡 192.168.100.1| SW
231+
HS[主机] -->|物理网卡 10.1.2.3| IN[外部网络 10.x.x.x]
232+
```
233+
234+
#### 仅主机模式 {#hostonly-mode}
235+
236+
仅主机模式类似 NAT,但是虚拟机不能与外部网络通信。
237+
238+
```mermaid
239+
flowchart TD
240+
VM1[虚拟机] -->|虚拟网卡 192.168.100.100| SW[虚拟交换机 192.168.1.x]
241+
VM2[虚拟机] -->|虚拟网卡 192.168.100.101| SW
242+
SW
243+
HSP[主机上的程序] -->|10.1.2.3| HS
244+
HSP -->|虚拟网卡 192.168.100.1| SW
245+
HS[主机] -->|物理网卡 10.1.2.3| IN[外部网络 10.x.x.x]
246+
```
247+
192248
### 已知问题 {#vm-known-issues}
193249

194250
#### 在 macOS VirtualBox 下闪屏 {#virtualbox-flicker}

docs/Ch03/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ $ cp [OPTION] SOURCE... DIRECTORY
594594

595595
??? tip "硬链接和软链接"
596596

597-
cp 的 `-l` 和 `-s` 参数分布为创建硬链接和软链接(又称为“符号链接”)。
597+
cp 的 `-l` 和 `-s` 参数分别为创建硬链接和软链接(又称为“符号链接”)。
598598

599599
简单而言,一个文件的硬链接和软链接都指向文件自身,但是在底层有不同的实现。
600600

docs/Ch04/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ $ tmux
341341

342342
更多功能,可以到这张 [cheatsheet](https://cheatography.com/bechtold/cheat-sheets/tmux-the-terminal-multiplexer/pdf/) 中查询。
343343

344-
关于 tmux 的更多介绍,可以参见[这篇博客](http://louiszhai.github.io/2017/09/30/tmux/)
344+
关于 tmux 的更多介绍,可以参见[这篇博客](http://louiszhai.github.io/2017/09/30/tmux/)[这篇 LUG Planet 文章](https://lug.ustc.edu.cn/planet/2025/07/how-to-use-tmux/)
345345

346346
??? note "Tmux 的工作原理"
347347

0 commit comments

Comments
 (0)