How does virtualbox get the network configurations?

2

I am installing CentOS 7 on virtualbox. On "Network & Host Name" screen:

enter image description here

When toggle the "OFF" to "ON", I can see the IP, DNS, netmask are all configured:

enter image description here

I am curious about how does virtualbox get all the network configurations. What happen when toggling the "OFF" to "ON"?

Nan Xiao

Posted 2015-05-26T06:58:44.633

Reputation: 3 535

Answers

0

The way VirtualBox configures networking in guests is by not only emulating the networking hardware associated with the VM, but it also creates a layer in between Host and Guest where it emulates a router.

The "Router" that VirtualBox emulates has settings which can be configured using the Virtual Machine Manager and when set to use its own DHCP server, the emulated router pushes settings to the client, as if the client was situated on a physical network using DHCP.

When toggling the Guest On/Off switch, it only applies to the Guest as it would if you were to setup CentOS on a physical machine, enabling and disabling the interface.

td512

Posted 2015-05-26T06:58:44.633

Reputation: 4 778

I am using NAT mode. But why the Guest can't connect to internet? Executing curl google.com, and the output is "curl(7): Failed tp connect to ...: Network is unreachable". – Nan Xiao – 2015-05-26T08:00:49.733

I'm guessing that you didn't tell CentOS to autostart networking. in which case, run sudo systemctl status network to check the status of networking, and if the service is in the stopped state, run sudo systemctl start network to start it. – td512 – 2015-05-26T08:07:11.670

Doesn't seem this cause. The status is Active: active(exited) since ...... Is this state right? – Nan Xiao – 2015-05-26T08:11:47.260

what's the output of ifconfig? – td512 – 2015-05-26T08:13:42.597

Because I can't copy easy from VM, so I catch screen shot for the ip addr. Sorry for the inconveience.

– Nan Xiao – 2015-05-26T08:19:00.993

What is the output of: sudo systemctl -l status network? – td512 – 2015-05-26T08:25:09.757

systemctl -l status network output: screen shot. – Nan Xiao – 2015-05-26T08:29:25.453

It looks like CentOS can't load/didn't finish loading networking in, and is having trouble with that – td512 – 2015-05-26T08:30:56.003

Why does this occur? Do I need re-install the OS? – Nan Xiao – 2015-05-26T08:32:45.687

I'm not sure. best thing to do would be to reload CentOS – td512 – 2015-05-26T08:33:47.090

OK, thanks very much for your time and effort! – Nan Xiao – 2015-05-26T08:55:30.600

The root cause is found in this discussion.

– Nan Xiao – 2015-05-27T08:47:16.113

1

When you are using the NAT mode of Virtualbox, an internal DHCP server is launched for the guests.

According to the doc, (https://www.virtualbox.org/manual/ch06.html#network_nat) the first card receives an IP in the subnet 10.0.2.0, the second in 10.0.3.0 and so on. This network can be modified (https://www.virtualbox.org/manual/ch09.html#changenat), but must be different of the host subnet.

Toine42

Posted 2015-05-26T06:58:44.633

Reputation: 444

0

When you toggle on/off, you're enabling and disabling an active link for interface of the VM. VirtualBox reports the config for the interface. It doesn't matter whether it be picking up the conifg from DHCP or it has a statically assigned IP.

Alex Atkinson

Posted 2015-05-26T06:58:44.633

Reputation: 2 845