VirtualBox, Linux, networking

This is for discussing general topics about how to use VirtualBox.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

VirtualBox, Linux, networking

Post by jtt89 »

I want to set up LAMP on Virtual Box on Windows7. I am wondering if it is possible to (regular cable modem from ISP connected to desktop through ethernet port, dynamic IP)

1) Connect from Windows7 to Linux (Apache, MySQL-server, etc...)
2) Connect from Linux to the Internet
3) Connect from Windows 7 to the Internet

...all at the same time?

Thank you.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VirtualBox, Linux, networking

Post by Perryg »

If you do not have a router you would use the Host-Only service to connect the host(win7) to the guest (centos)
Then add a second adapter set to NAT so the guest can access the Internet.

See Chapter 6 Virtual Networking in your VirtualBox users manual.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

Thanks. I am not sure if I understand this, but having a router would mean running Windows and Linux on two separate machines, and that would not have anything to do with VirtualBox, right (I am not talking about any kind of network etc, just one user, but Linux and Windows; better if on one machine for now).
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VirtualBox, Linux, networking

Post by Perryg »

Actually no that is not what it means.

Simple question: Is there a router in your network?
If the answer is no then use the host-only service to connect the guest and host.
If the guest needs access to the Internet, add a second virtual NIC set to NAT.

Have you read Chapter 6 in your VirtualBox users manual?
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

I dont have a router at home. Just one computer plugged in to the Internet through cable modem. I have a manual, but I did not read it yet, but it is good to know that there is gonna be info about how to do that there. Thank you.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

I read the manual but there is not much info about it. I already set up to Adapters as active - 1: Host-only Adapter, 2: NAT. Would you be able to tell me if there is anything else that needs to be done, like changing some network settings in Control Panel in Win7 (host) etc?

1) How do I connect to the guest Apache server with Internet Explorer? What address do I physically enter in the browser?
2) How would I connect to the guest (Linux) with an SSH client from Win7. What would be the addresses and ports that I would use.

If there is any good website about it on the Internet, please let me know also. I know it can be done, but there is no info about it. Thank you.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VirtualBox, Linux, networking

Post by Perryg »

ipconfig /all in a Windows command window will show you the addresses available on the Windows host.
ifconfig -a does the same thing in Linux.

You would use the 192.168.56.* address range to talk to the guest from the host and vice versa.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

Thank you, I was actually just looking at that:

CENTOS:

[root@localhost ~]# ifconfig eth0 Link encap:Ethernet HWaddr 08:00:27:2B:94:89
inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe2b:9489/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:138 errors:0 dropped:0 overruns:0 frame:0 TX packets:31 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:17657 (17.2 KiB) TX bytes:6173 (6.0 KiB)

eth1 Link encap:Ethernet HWaddr 08:00:27:2B:FC:6D
inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe2b:fc6d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2167 errors:0 dropped:0 overruns:0 frame:0 TX packets:2091 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:943172 (921.0 KiB) TX bytes:194809 (190.2 KiB)

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:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:720 (720.0 b) TX bytes:720 (720.0 b)

WIN7

C:>ipconfig

Windows IP Configuration

Ethernet adapter Local Area Connection:

IPv4 Address: 62.21.38.13
Subnet Mask: 255.255.254.0
Default Gateway: 62.21.32.1

Ethernet adapter VirtualBox Host-Only Network:

IPv4 address: 192.168.56.1
Subnet Mask: 255.255.255.0
Default Gateway: (empty)

- - - - - - - - -
I just tried http://192.168.56.1/ in a browser and it did not work, Apache is running.... It might be something with the Linux configuration though.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VirtualBox, Linux, networking

Post by Perryg »

Seems to me if the Apache server is on Centos you would use the 192.168.56.101 address since that is what it is using.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

>Thanks for everyone's help!
>It worked in the end to access the guest os server from a host os browser by using the IP address as returned from inside the guest os.
>(I was making the mistake of trying to figure out the ip address from the host os side)

>What I found fixed the issue for me was making sure that the windows VirtualHost-Only adapter was set to the .1 address for the ip range so
>my virtual box host only adapter was 192.168.58.20 but the ip for the Windows adapter is 192.168.58.1

I still did not configure the Apache and I dont have too much experience with that, so it might be something with that also (like setting up the hostname, config files lie /etc/httpd/confg/httpd.confg and /etc/sysconfig/network; I know there is something like #NameVirtualHost *:80 <needs to be uncommented> etc...)
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

http://192.168.56.101/ works from withing Linux (it goes to the default Apache page), but not from Windows. http://192.168.56.1/ does not work anywhere

I can ping both 192.168.56.1 and 192.168.56.101 from Win cmd and get results...
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VirtualBox, Linux, networking

Post by Perryg »

If your Host-only adapter is configured as default ( what VirtualBox suggests) the addresses will be as follows.
host = 192.168.56.1
guests = 192.168.56.101

You would access the guest using 192.168.56.101 from the host in your browser. If it doesn't work I would look at the Windows firewall as an issue. See screen shots for the exact settings. These can be configures in the VirtualBox main manager -> preferences -> networking.
host-only-1.png
host-only-1.png (25.24 KiB) Viewed 4360 times
host-only-2.png
host-only-2.png (28.41 KiB) Viewed 4360 times
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

I turned off Windows Firewall and that did not make a difference. I will look at Main Manager in a minute, if thats something else than File -> Preferences... or File -> Virtual Media Manager. As far as CentOS -> Settings -> Network, is the following correct:

1)
Attached to: Host-only Adapter
Name: VirtualBox Host-Only Ethernet Adapter
Adapter Type: Intel PRO/1000 MT Server (82545EM) <I had Desktop before>
Promiscuous Mode: Deny
Mac Address: <some number here>
Cable connected: <checked>

2)
Attached to: NAT
Adapter type: Intel PRO/1000MT Desktop (82540EM)
Mac Address: <some number>
Cable connected: <checked>

I think that Apache is configured / working fine (it works withing Linux too)
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: VirtualBox, Linux, networking

Post by Perryg »

Refer to my previous post.
jtt89
Posts: 23
Joined: 20. Nov 2011, 12:56
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: VirtualBox, Linux, networking

Post by jtt89 »

I went to File -> Preferences -> Network -> Host-only Network Details and I changed the settings according to the previous post. Every time I try to click OK and get out I get a message: Do you want the following program to make the changes (it is some VB .exe program). No matter if I choose Yes or No, the settings in the Adapter window (of that Host-only Network Details window) change to something else (different IP and subnet mask), like it would not want to accept it etc.
That probably does not make a difference, but I had Widnows Firewall turned off.

Addresses that it is changing to:

Ethernet adapter VirtualBox Host-Only Network:

Autoconfiguration IPv4 Address: 169.254.170.66 (Preferred)
Subnet Mask: 255.255.0.0

Thats from Win cmd
Post Reply