virtualbox: How is the Gateway IP of a guest OS determined when configured as NAT

3

2

In a host system, a gateway generally refers to the IP address of either a router or a network segment. Generally, the output of route PRINT or route -n corroborates to the actual IP of my gateway.

D:\temp>route PRINT
===========================================================================
Interface List
 61...20 68 9d 64 a4 ea ......Bluetooth Device (Personal Area Network)
 47...60 67 20 b1 5c 9a ......Intel(R) Centrino(R) Advanced-N 6205
 43...d4 be d9 60 de 2b ......Intel(R) 82579LM Gigabit Network Connection
142...08 00 27 00 98 7d ......VirtualBox Host-Only Ethernet Adapter
  1...........................Software Loopback Interface 1
===========================================================================

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.1.1    192.168.1.100     25
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    306

For a guest system, what is the gateway IP when using NAT? As an example, when I issued the following command route -n, the output is

abhijit@abhijit-VirtualBox ~ $ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.3.2        0.0.0.0         UG    0      0        0 eth1
10.0.3.0        0.0.0.0         255.255.255.0   U     1      0        0 eth1

Why is this Gateway IP 10.0.3.2 and how is it assigned?

Abhijit

Posted 2015-05-01T16:54:28.117

Reputation: 205

Answers

1

The gateway should be the host interfaces private IP address. In this case, the host is acting as a router. If you view the VirtualBox log for the VM on the host, you should be able to search for that address and see that it is assigned by a virtual DHCP service.

NAT: DHCP offered IP address 10.0.2.15

The above is an example from my own PC running Linux Mint as a VM.

Julian Knight

Posted 2015-05-01T16:54:28.117

Reputation: 13 389