
我在 centos 機器上的虛擬機中設定了 2 個虛擬機,但 NAT 配置似乎無法如預期運作。作為前言,我想提醒一下 virtualbox 手冊中有關 NAT 配置的內容(來源:https://www.virtualbox.org/manual/ch06.html#network_nat):
[...]它不需要在主機網路和來賓系統上進行任何設定。因此,它是 Oracle VM VirtualBox 中的預設網路模式。
[...]虛擬機器從整合到 Oracle VM VirtualBox 中的 DHCP 伺服器接收其在專用網路上的網路位址和配置
第一張卡連接到專用網路 10.0.2.0,第二張卡連接到網路 10.0.3.0,依此類推。
我的配置:
# - 主持人 - #
cat /etc/os-release
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
uname -a
Linux localhost.localdomain 4.18.0-536.el8.x86_64 #1 SMP Thu Jan 18 15:15:29 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
virtualbox:
版本 7.0.14 r161095 (Qt5.15.3)
未安裝擴充包。
未安裝訪客新增。
free -h
total used free shared buff/cache available
Mem: 11Gi 3.4Gi 5.9Gi 818Mi 2.2Gi 7.0Gi
Swap: 5.8Gi
grep 'processor\|model name' /proc/cpuinfo
processor : 0
model name : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
processor : 1
model name : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
processor : 2
model name : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
processor : 3
model name : Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
cat /var/log/vbox-setup.log*
Building the net filter module.
Building the net adapter module.
Building the main VirtualBox module.
Building the main VirtualBox module.
Building the main VirtualBox module.
cat ./Xorg.*.log | grep -i box
no output
# - 客人 - #
基本記憶體:1024 MB
1個CPU
在虛擬機器日誌中,看起來沒有 NAT 相關錯誤。
我想配置NAT。
在檔案 -> 工具 -> 網路管理員 -> NAT 網路中:
NatNetwork 10.0.2.0/24,啟用DHCP(是的,我知道“Nat 網路”在vbox 術語表中不是“NAT”,但沒有NAT 選項卡)。
VM 上的網路設定:
附加至:
已檢查 NAT 電纜已連接
ip -br -c addr
lo UNKNOWN 127.0.0.1/8 ::1/128
enp0s3 UP
enp0s8 DOWN
virbr0 DOWN 192.168.122.1/24
virbr0-nic DOWN
正如您所看到的,網路 10.0.2.0/24 沒有顯示任何 ip。我錯過了什麼?
謝謝大家!