LoginSignup
7
10

More than 5 years have passed since last update.

VirtualBoxにおけるNATとNAT Networkの違い

Posted at

VirtualBoxのSettings>NetworkのAttached toは、デフォルトでNATになっていますが、NAT Networkというのも選べます。一体何が違うのでしょうか?

Screen Shot 2018-12-16 at 9.26.40.png

NATとは

NATとは、IPアドレスを異なるIPアドレスに変換してくれるものです。ルーターがこの役割を担うことが多く、プライベートIPアドレスとグローバルIPアドレスを変換してくれています。

VirtualBoxのNATの役割

VirtualBoxの場合は、

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

とある通り、virtual machineから、外のネットワークにアクセスする時に使われます。NATが、virtual machineとhostとの間に位置し、virtual machineのIPアドレスを変換しています。

NAT Networkとの違いは何か

デフォルトのNATでは、virtual machine同士で接続が出来ません。

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.

virtual machine同士で接続出来るようにしたのが、NAT service(NAT Networkのこと)です。

実際にやってみた

今、WindowsとUbuntuの2つのvirtual machineを立ち上げました。

Windowsは、Networkを最初からNAT Networkに。UbuntuはNATに設定しました。

UbuntuのIPアドレスを確認し、Windowsからpingを実行してみます。

C:\Users\IEUser>ping 10.0.2.15

Pinging 10.0.2.15 with 32 bytes of data:
Reply from 10.0.2.4: Destination host unreachable.
Reply from 10.0.2.4: Destination host unreachable.
Reply from 10.0.2.4: Destination host unreachable.
Reply from 10.0.2.4: Destination host unreachable.

Ping statistics for 10.0.2.15:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

unreachableと言われました。

そこで、UbuntuのNetworkをNAT Networkに変更し、同じ試行をやります。

C:\Users\IEUser>ping 10.0.2.5

Pinging 10.0.2.5 with 32 bytes of data:
Reply from 10.0.2.5: bytes=32 time<1ms TTL=64
Reply from 10.0.2.5: bytes=32 time<1ms TTL=64
Reply from 10.0.2.5: bytes=32 time<1ms TTL=64
Reply from 10.0.2.5: bytes=32 time<1ms TTL=64

Ping statistics for 10.0.2.5:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

今度は送れました。

最後に

Networkの設定は、いろいろオプションがありますね。知らないと、よく分からず詰まってしまうので留意しておく必要がありまあすね。

以下に、VirtualBoxのサイトにあった表を貼っておきます。

Screen Shot 2018-12-16 at 11.02.19.png

参考

7
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
10