LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Network Connection to Virtual Machine? (https://www.linuxquestions.org/questions/linux-newbie-8/network-connection-to-virtual-machine-914168/)

greendragons 11-17-2011 10:59 PM

Network Connection to Virtual Machine?
 
Hello,
I am running Ubuntu 11.04 and running Slackware on virtual box, i am unable to connect Slackware to Ubuntu..
Code:

root@darkstar:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:17:7f:3d 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:34 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1940 (1.8 KiB)  TX bytes:1940 (1.8 KiB)

root@darkstar:~# ping 10.116.28.219
connect: Network is unreachable

while on Ubuntu vmboxnet0 is up.....
how to setup connection between my ubuntu machine and my virtual machine....


Thnx!!

davemguru 11-18-2011 12:31 AM

Quote:

Originally Posted by greendragons (Post 4527165)
Hello,
I am running Ubuntu 11.04 and running Slackware on virtual box, i am unable to connect Slackware to Ubuntu..
Code:

root@darkstar:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:17:7f:3d 
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:34 errors:0 dropped:0 overruns:0 frame:0
          TX packets:34 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1940 (1.8 KiB)  TX bytes:1940 (1.8 KiB)

root@darkstar:~# ping 10.116.28.219
connect: Network is unreachable

while on Ubuntu vmboxnet0 is up.....
how to setup connection between my ubuntu machine and my virtual machine....


Thnx!!

Your 'ifconfig' doesn't show any IP address assigned to eth0 inside your virtual machine.
So, in the VirtualBox Manager Gui - for the slackware VM - look at the settings for NETWORK.
You will have 4 adapters.

On the tab for adapter 1;
1) is it enabled?
2) Under "Attaached to" what type of network have you got? NAT/Bridged/Internal etc. ?
3) Click the Advanced button - is "Cable Connected" checked?
4) The "Adapter type" could be your problem - if the one that is selected is not supported "out of the box" by slackware.

What sort of "virtual networking" do you want? In other words - what do you want the Ubuntu host to be able to do (if anything) with the slackware VM? Maybe you don't want the slackware VM to be able to "get into" or "see" anything in the Ubuntu host?
OR
Maybe you want the slackware VM to see ONLY the Ubuntu host and not get out to the outside world? There are all sorts of combinations.
The default suits a lot of situations and that is NAT.
https://www.virtualbox.org/manual/ch06.html Chapter 6 of the virtualBox manual discusses the many networking options.

There is also a log of what was setup at runtime on the VM --> right click on the name of the VM in the VirtualBox Manager Gui - you should see the choice of "Show Log". The window that opens will have a log "tab" for each execution/run of the VM. The most recent run being the current tab. You could save the log and post it here. It may help.
Dave

Randymanme 11-18-2011 12:48 AM

Hi,

I had the same problem when I installed Mint 12 in Virtualbox with Mint 11 hosting. Here's what I did to solve that problem. Power off your guest and select settings (you can't change settings with the virtual machine running or saved in the machine state). Under Network, Adapter 1, check "Enable Network Adapter." It was set to "NAT" by default (and didn't work). Under "Attached To," I changed it to "Bridged Adapter." This bridged my guest's (Mint 12) network interface to the host's (Mint 11) internet connection. That fixed it.

greendragons 11-18-2011 01:28 AM

When machine is powerd off then in tab 1 it shows enabled and NAT is selected....
but whn machine boots up that enabled check is no more there....
Im using default NAT
And adpater is Intel Pro 1000MT....

---------- Post added 11-18-11 at 02:29 AM ----------

Quote:

Originally Posted by Randymanme (Post 4527236)
Hi,

I had the same problem when I installed Mint 12 in Virtualbox with Mint 11 hosting. Here's what I did to solve that problem. Power off your guest and select settings (you can't change settings with the virtual machine running or saved in the machine state). Under Network, Adapter 1, check "Enable Network Adapter." It was set to "NAT" by default (and didn't work). Under "Attached To," I changed it to "Bridged Adapter." This bridged my guest's (Mint 12) network interface to the host's (Mint 11) internet connection. That fixed it.

I tried that but it wasn't woring either....

greendragons 11-18-2011 02:28 AM

Quote:

Originally Posted by davemguru (Post 4527228)

What sort of "virtual networking" do you want? In other words - what do you want the Ubuntu host to be able to do (if anything) with the slackware VM? Maybe you don't want the slackware VM to be able to "get into" or "see" anything in the Ubuntu host?
OR
Maybe you want the slackware VM to see ONLY the Ubuntu host and not get out to the outside world? There are all sorts of combinations.

Dave

I want to setup server on host and test it from guest... for learning purpose...
how to configure it to connect to host... the blue screen at the bottom shows that it is connected to the host...but i can't ping... i tried to configure using netconfig but i couldn't succeed...

davemguru 11-19-2011 06:31 AM

Quote:

Originally Posted by greendragons (Post 4527299)
I want to setup server on host and test it from guest... for learning purpose...
how to configure it to connect to host... the blue screen at the bottom shows that it is connected to the host...but i can't ping... i tried to configure using netconfig but i couldn't succeed...

OK - couple of things.
Because you want to test a host application from your guest. Then NAT will not be the ideal solution. Vbox has something perfectly suited to what you want. BTW did you read the chapter 6?.

First - CHANGE YOUR NETWORK ADAPTER TYPE from "Intel Pro 1000MT" to something a lot simpler - I suggest PCnet-PCI II (Am79C970A) BECAUSE - (and it's only a guess) slackware may not support the more advance gigabit adapter. Start with the "lowest common denominator first" is a good adage. The Am79C970A is much older - and therefore more likely to be supported by older distros. From Chapter 6 ---
Quote:

The PCNet FAST III is the default because it is supported by nearly all operating systems out of the box, as well as the GNU GRUB boot manager. As an exception, the Intel PRO/1000 family adapters are chosen for some guest operating system types that no longer ship with drivers for the PCNet card, such as Windows Vista
Second - LEAVE IT AT NAT - boot the system (and I mean boot/Start - don't restore a SAVE) and then just run a web browser... any web browser. If you can "see the outside world" - browse a page or two - then the adapter is working.

You know you can RIGHT click the little blue screen icon at the bottom of your VM encompassing window - the one for networks - and then you can change SOME things - while your VM is running - like you can connect/disconnect the cable. Just like you can in real life.

There is a "mini dhcp server" built in to the VM when you run it with NAT (it is turned off for bridged networking -- coz it assumes you will either use a static IP or you have a DHCP server somewhere on your REAL network. AGAIN - from chapter 6
Quote:

The virtual machine receives its network address and configuration on the private network from a DHCP server integrated into VirtualBox. The IP address thus assigned to the virtual machine is usually on a completely different network than the host. As more than one card of a virtual machine can be set up to use NAT, the first card is connected to the private network 10.0.2.0, the second card to the network 10.0.3.0 and so on.
The virtual dhcp server and DEFAULT GATEWAY is 10.0.2.2
Your VM machine's address will be 10.0.2.x - where x >3
(address 10.0.2.3 is reserved for a virtual tftp server - in case you wanted to network/PXE boot your os)

The address of your host from inside the VM will be 10.0.2.2
So, if you had a webserver running on your host at port 80 then to access it from within your VM you would use http://10.0.2.2:80.

When your VM is running with NAT it is insulated from the outside world and from your host. This is why it is the default (and safest). You can "get to it" by using the "port mapping" facility. BUT NOT WITH A STANDARD PING.
However, as suggested by other contributers - you may want to use BRIDGED rather than NAT for reasons outlined in chapter 6 of the virtualbox manual.

Some people would setup a new/development server - e.g. sql server or web server in a VM and test that way. One could even setup a "suite of machines" clients and servers in a group of VM's - all of which can "see each other" in their own private network.
I STRONGLY urge you to read chapter 6 of the virtualbox manual.

Dave


If I have helped - can you "click my rep" and indicate that I have done so.

greendragons 11-19-2011 11:03 AM

Quote:

Originally Posted by davemguru (Post 4528238)
OK - couple of things.
First - CHANGE YOUR NETWORK ADAPTER TYPE from "Intel Pro 1000MT" to something a lot simpler - I suggest PCnet-PCI II (Am79C970A) BECAUSE - (and it's only a guess) slackware may not support the more advance gigabit adapter. Start with the "lowest common denominator first" is a good adage. The Am79C970A is much older - and therefore more likely to be supported by older distros. From Chapter 6 ---


Thnx alot... i was able to connect guest to host.. i used PCnet III adapter...the whole problem was coz of adapter only...
:) now i can set up server on host and test on guest...


All times are GMT -5. The time now is 08:01 AM.