NAT & Bridged Networking

Coder阿飛發表於2020-12-02

參考自VirtualBox官網:https://www.virtualbox.org/manual/UserManual.html#networkingdetails

 NAT Network

Network Address Translation (NAT) is the simplest way of accessing an external network from a virtual machine.

Usually, it does not require any configuration on the host network and guest system. For this reason, it is the default networking mode in Oracle VM VirtualBox.
A virtual machine with NAT enabled acts much like a real computer that connects to the Internet through a router. The router, in this case, is the Oracle VM VirtualBox networking engine, which maps traffic from and to the virtual machine transparently. In Oracle VM VirtualBox this router is placed between each virtual machine and the host. This separation maximizes security since by default virtual machines cannot talk to each other.

 

The Network Address Translation (NAT) service works in a similar way to a home router, grouping the systems using it into a network and preventing systems outside of this network from directly accessing systems inside it, but letting systems inside communicate with each other and with systems outside using TCP and UDP over IPv4 and IPv6.

Brideged Network

This is for more advanced networking needs, such as network simulations and running servers in a guest. When enabled, Oracle VM VirtualBox connects to one of your installed network cards and exchanges network packets directly, circumventing your host operating system's network stack.

 

With bridged networking, Oracle VM VirtualBox uses a device driver on your host system that filters data from your physical network adapter. This driver is therefore called a net filter driver. This enables Oracle VM VirtualBox to intercept data from the physical network and inject data into it, effectively creating a new network interface in software. When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable. The host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.

 NAT Network 總結:

1、無需配置即可訪問外網,簡單快捷,因此是VirtualBox預設模式;

2、啟用了NAT的虛擬機器的行為就像是一臺通過路由器連線到Internet的真實計算機。在這種情況下,路由器是Oracle VM VirtualBox網路引擎,該引擎透明地對映來往虛擬機器的流量。在Oracle VM VirtualBox中,此路由器放置在每個虛擬機器和主機之間。由於預設情況下虛擬機器無法相互通訊,因此這種隔離可最大程度地提高安全性;

3、NAT模式的缺點是,就像路由器後面的專用網路一樣,虛擬機器是不可見的,並且無法從外部Internet訪問。除非設定埠轉發,否則無法以這種方式執行伺服器;

4、NAT有限制:

  • ICMP協議限制。 一些常用的網路除錯工具(例如 pingtraceroute)依賴於ICMP協議來傳送和接收訊息。Oracle VM VirtualBox ICMP支援有一些限制,這

意味著ping應該可以工作,但其他一些工具可能無法可靠地工作。

  • 接收UDP廣播。來賓不能可靠地接收UDP廣播。為了節省資源,訪客僅在特定埠上傳送UDP資料後,它僅偵聽一定時間。因此,基於廣播的NetBios名稱解析並非

始終有效,但WINS始終有效。解決方法是,可以在 符號中使用所需伺服器的數字IP 。 \\server\share

  • 不支援某些協議。不支援TCP和UDP以外的協議。不支援GRE。這意味著不能使用某些VPN產品,例如Microsoft的PPTP。還有其他僅使用TCP和UDP的VPN產品。
  • 轉發低於1024的主機埠。在基於UNIX的主機(例如Linux,Oracle Solaris和Mac OS X)上,無法從不能執行的應用程式繫結到低於1024的埠 root。因

此,如果您嘗試配置此類埠轉發,則VM將拒絕啟動。

 

Brideged Network 總結:

1、為更高的網路需求服務;

2、通過橋接網路,Oracle VM VirtualBox使用宿主機Host系統上的裝置驅動程式來過濾來自物理網路介面卡的資料。使VirtualBox可以攔截來自物理網路的資料並將資料注入到其中,從而有效地在軟體中建立新的網路介面。當虛擬機器Guest使用這種新的軟體介面時,它看起來像是使用網路電纜將Guest物理連線到主機系統的主機系統Host可以通過該介面向Guest傳送資料,並從中接收資料

 

Plus:

Mode

VM→Host

VM←Host

VM1↔VM2

VM→Net/LAN

VM←Net/LAN

Host-only

+

+

+

Internal

+

Bridged

+

+

+

+

+

NAT

+

Port forward

+

Port forward

NATservice

+

Port forward

+

+

Port forward

 

 

相關文章