Bridged Adapter vs. Host-only

Discussions related to using VirtualBox on Windows hosts.
Post Reply
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Bridged Adapter vs. Host-only

Post by jtt89 »

I would like to connect Linux guest on Windows host and there is not too much info about it in the manual. Does anybody know if Bridged Adapter option (a lot of people recommend that, about 80%) is reserved only for people who have a router (physical device at home), and if I dont have one I need to stick to Host-only option? As far as I understand both Bridged, and Host-only can be mixed with NAT in order to provide access to the internet for the guest (Linux).

Thank you in advance for any info.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Bridged Adapter vs. Host-only

Post by mpack »

Lets not go overcomplicated: if your guest is using bridged, it generally does not also need to use either NAT or host only, as a bridged network can do everything that those do.

But yes, bridged works best if it provides a connection (using NIC or wireless) to a physical router which incorporates a DHCP server to assign IP addresses. Otherwise you would have to know how set such things up manually.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: Bridged Adapter vs. Host-only

Post by jtt89 »

So that means that I can use either one of these options? (not having a router)

1) Bridged Adapter only (but it is more complicated to set it up)
2) Host-only Adapter + NAT at the same time
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Bridged Adapter vs. Host-only

Post by Perryg »

@jtt89,
As I have explained several times to you is several different topics, "you CAN NOT use Bridged if you do not have a router".
I don't know how much clearer to make this.
You must use host-only and a second adapter set to NAT.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: Bridged Adapter vs. Host-only

Post by jtt89 »

Thank you. I am still trying to piece all the information and eliminate some of the options, so I can make sure I am going in the righgt direction with this. I updated VB to the newest version and reinstalled Linux all over again. I have it at Host-only and NAT and I am sure that all the settings are correct as I wasnt making any changes. I am trying to use Putty to connect to the guest from Windows, and it doesnt seem to work...
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Bridged Adapter vs. Host-only

Post by mpack »

Perryg wrote:you CAN NOT use Bridged if you do not have a router
Was what I said above not correct? Is it not only the DHCP stuff which will fail? Can this not be corrected using a fixed IP?

OTOH I agree that jtt89 is effectively prohibited from using bridged without a router, because he doesn't have enough experience to work around it.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: Bridged Adapter vs. Host-only

Post by Perryg »

Effectively the VirtualBox Bridged adapter is going to be looking at a router to handle the hand-off of the packets regardless of DHCP. Yes there are work-arounds but natively it is going to struggle and fail.

jtt89 just has a cable modem or similar plugged directly into the host, nothing that can handle the routing. You don't have a real address to put in the guest and can't share the same IP that is associated to the host. So short of buying a cheap router or setting the host to provide the routing I don't see a way this will work other than host-only with NAT as second adapter for the Internet.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Bridged Adapter vs. Host-only

Post by mpack »

Ah - ok. Bridged requires a NIC or a wireless adapter, so obviously it will not work on systems that don't have that (e.g. a USB/ADSL dialup modem). I mistakenly assumed that if the OP was considering bridged then he must have the basic architecture for it.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: Bridged Adapter vs. Host-only

Post by jtt89 »

How would NAT "only" with port forwarding fit into the picture?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Mostly XP

Re: Bridged Adapter vs. Host-only

Post by mpack »

NAT uses your hosts network connection at a higher level, so doesn't care about whether your lower levels include a NIC or wireless or not.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: Bridged Adapter vs. Host-only

Post by jtt89 »

I was thinking about something like this:

Edit the xml configuration file for our virtual machine. On Windows, it’s inside the .VirtualBox/Machines subdirectory in your home folder.
At the top of the file you should see an <ExtraData> tag. Inside that tag, copy in the following tags:

Code: Select all

<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222"/>  
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/>  
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/>  
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8888"/>  
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80"/>  
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"/> 
These lines configure VirtualBox to forward requests to specific ports on the host system onto other specified ports on the guest system. For SSH, we’re forwarding port 2222 of the host system to port 22 of the guest system (where OpenSSH is listening). The same principle applies to the Apache configuration items, with port 8888 on the host mapping to port 80 on the guest.


Again, I am asking mostly from my point of view (cable modem, no router). I know that the primary method is Host-only + NAT, but thats another option, so I am wondering what are the pros and cons.

Thank you.
Post Reply