[SOLVED] Diskless VM internet access

Discussions about using Linux guests in VirtualBox.
Post Reply
mo0nykit
Posts: 16
Joined: 5. Aug 2009, 17:18
Primary OS: MS Windows XP
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu Linux 9.04
Location: Cebu City, Philippines

[SOLVED] Diskless VM internet access

Post by mo0nykit »

Hi everyone!
I'd like to start with the question I have in mind:
How can a diskless VM (boots from network) access the Internet?

Here's the setup I have:
1. Router (WAN IP is dynamic, LAN IP 192.168.1.1)
2. Windows XP host (local IP 192.168.1.2)
3. Server VM is Ubuntu. It has two network interfaces:
eth0 is a VirtualBox Bridged Adapter. LAN IP 192.168.1.3
eth1 is a VirtualBox Internal Network Adapter. LAN IP 192.168.100.1
4. Client VM is diskless. It boots from the Server VM. I got it to work by following this guide (Setting Up A Diskless-boot Kerrighed 2.3.0 Cluster in Ubuntu 8.04) and some suggestions in the corresponding forum. Note that I'm NOT doing a Kerrighed boot yet, just an Ubuntu base system. It has one network interface.
eth0 is a VirtualBox Internal Network Adapter. LAN IP 192.168.100.100. This is a fixed address as I have set it up with the DHCP Server at the Server VM.
Okay, so now everything is up and running.
1. At the Server VM, I chroot into the bootable file system, edit /etc/apt/sources.list as necessary and execute

Code: Select all

sudo aptitude update
Everything goes well, since the Server VM has flawless access to the Internet.

2. Then I login to the Client VM. When I try the following command, for example:

Code: Select all

sudo apt-get install nano
apt-get can read the package lists since I have done an update before. When I actually proceed with the installation, (e.g. press Y), the Client VM can't access the Internet.

3. Another test for outside access:

Code: Select all

ping 192.168.100.1
Good! :D

Code: Select all

ping 192.168.1.3
Good! :D This is the Server VM's Bridged Adapter

Code: Select all

ping 192.168.1.2
Bad :( This the host machine's LAN IP. I have Wireshark on, and it doesn't get the pings. Firewall doesn't log incoming pings either.

4. Now I return to the Server VM, and check its routing tables

Code: Select all

route -vn
There is an entry for the default route 0.0.0.0

Code: Select all

Destination 0.0.0.0
Gateway 192.168.1.1
Genmask 0.0.0.0
Flags UG
Metric 0
Ref 0
Use 0
Iface eth0
So that's my situation. I might be missing something. Does "Internal Network Adapter" mean that it's ONLY for the internal network? Can't packets originating from the virtual internal network be routed? If so, is there a workaround for this? Now I go back to my first question:
How can a diskless VM (boots from network) access the Internet?

I'm doing this as a practice setup for a Beowulf cluster (eventually) before I get my hands on the actual hardware.

I'm sorry if the post is too long, I just want to provide as many details as possible.

Thanks in advance for your help!
Last edited by mo0nykit on 17. Sep 2009, 05:33, edited 1 time in total.
Health in HEART, MIND, BODY and SOUL
mo0nykit
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Diskless VM internet access

Post by Sasquatch »

If only more users would post such extensive information :roll:. It's perfect.

Now, you guessed it right, and the manual confirms it, Host-Only, or Internal Networking does not allow external excess. The only way to get that working, is to set up some kind of routing on a machine that has access to internet and the VM you want to give internet. It's actually a lot simpler if you just provide a second NIC and attach it to NAT. There, you're done.
Or, that's also something you can do, is change the NIC type to Bridged. That way, you would need only one NIC and you can boot the VM over the network and have internet at the same time, all through one NIC.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
mo0nykit
Posts: 16
Joined: 5. Aug 2009, 17:18
Primary OS: MS Windows XP
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu Linux 9.04
Location: Cebu City, Philippines

Re: Diskless VM internet access

Post by mo0nykit »

@Sasquatch
Thanks for the suggestions :)

Okay so here is what I did:
1. No changes in the Server VM.
2. Client VM now has two network interfaces:
eth0 is unchanged from previous setup
eth1 is a VirtualBox Bridged Adapter
Now I fire up the Client VM:
1. Network boot doing fine.
2. Login doing fine.
3. Then I issue the following commands:

Code: Select all

sudo ifconfig eth1 192.168.1.4
sudo ifconfig eth1 up
IMO, since there is no network-manager which automatically sets up the network, I'll have to do this manually.
4. I checked the Client VM's routing table:

Code: Select all

route -vn
And I get the following information for the default route:

Code: Select all

Destination 0.0.0.0
Gateway 192.168.100.1
Genmask 0.0.0.0
Flags UG
Metric 0
Ref 0
Use 0
Iface eth0
5. We'll need to change the gateway for the default route so that it will point to the router:

Code: Select all

sudo route add default gw 192.168.1.1
sudo route del default gw 192.168.100.1
6. Oh, I forgot to say that I already set up the DHCP server to provide as DNS 208.67.220.220, which is the IP address for OpenDNS.
7. Testing for connections

Code: Select all

ping 192.168.100.1
ping 192.168.1.3
ping 192.168.1.2
ping 192.168.1.1
ping 208.67.220.220
ping www.google.com
My diskless VM can now access the Internet! :D Yey!

The other suggested setup
For this setup, Sasquatch suggested that both VM's will each have a Bridged Adapter. Apparently this doesn't work. DHCP Server fails to start when I set it to listen at 192.168.1.3 (The Server VM's eth0 Bridged Adapter). I don't know why. I haven't done extensive experiments on this. Feel free to report on what you have encountered.
Health in HEART, MIND, BODY and SOUL
mo0nykit
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Diskless VM internet access

Post by Sasquatch »

The problem with running a DHCP on a bridged adapter, is that the existing DHCP, like a router, can block such requests. Instead of doing a DHCP from the router, disable that one, put all the physical network clients like your Host to static, so they can still access and use the router, and let the Server play the role of DHCP. For the best results, use the same range the Router already provided, so you don't need to change the IP configuration again to get internet access. The gateway IP is of course the router. The result might be a bit slower, because all traffic goes through the router.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
mo0nykit
Posts: 16
Joined: 5. Aug 2009, 17:18
Primary OS: MS Windows XP
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu Linux 9.04
Location: Cebu City, Philippines

Re: Diskless VM internet access

Post by mo0nykit »

Hello! Sorry for the late update. Had exams last weekend.

@Sasquatch
Okay, I did as you suggested.
1. I disabled the router's DCHP server
2. And I now use only one bridged adapter for each VM.

DHCP now works fine.
TFTP now works fine. Can actually load up the initrd.img and vmlinuz.
But I think there is a problem with the NFS already. The console stops dead at this point:

Code: Select all

IP-Config: eth0 complete (from 192.168.1.3):
 address: 192.168.1.100     broadcast: 192.168.1.255     netmask:255.255.255.0
 gateway: 192.168.1.1       dns0     : 208.67.220.220    dns1   : 0.0.0.0
 host   : node_01
 domain : example.org
 rootserver: 192.168.1.3 rootpath: 192.168.1.3:/home/nfsroot
 filename  : /pxelinux.0
Begin: Running /scripts/nfs-premount ...
Done.
connect: Connection timed out
Here is my /etc/exports file:

Code: Select all

# /etc/exports
/home/nfsroot 192.168.1.0/255.255.255.0(rw,no_subtree_check,async,no_root_squash)
/home/node_01 192.168.1.0/255.255.255.0(rw,no_subtree_check,async,no_root_squash)
Am I missing some other NFS configuration?

Thanks!

EDITED: Typographical error
Health in HEART, MIND, BODY and SOUL
mo0nykit
mo0nykit
Posts: 16
Joined: 5. Aug 2009, 17:18
Primary OS: MS Windows XP
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Ubuntu Linux 9.04
Location: Cebu City, Philippines

Re: Diskless VM internet access

Post by mo0nykit »

All right I found a solution to my problem :D
I forgot to update my /var/lib/tftpboot/pxelinux.cfg/default
Previously,

Code: Select all

LABEL linux
KERNEL vmlinuz-2.6.28-15-generic
APPEND console=tty1 root=/dev/nfs initrd=initrd.img-2.6.28-15-generic nfsroot=192.168.100.1:/home/nfsroot ip=dhcp rw
I changed it to:

Code: Select all

LABEL linux
KERNEL vmlinuz-2.6.28-15-generic
APPEND console=tty1 root=/dev/nfs initrd=initrd.img-2.6.28-15-generic nfsroot=192.168.1.3:/home/nfsroot ip=dhcp rw
Note the change in the IP address of nfsroot=. . . at the APPEND line.

About DHCP on the router
I reenabled the DHCP services on my router since there are other people in the house who might want to use the Internet with their own PCs.
I mentioned in a previous post:
DHCP Server fails to start when I set it to listen at 192.168.1.3 (The Server VM's eth0 Bridged Adapter). I don't know why. I haven't done extensive experiments on this. Feel free to report on what you have encountered.
I didn't know how to get around this since I didn't know yet how to view the syslog file.

Code: Select all

tail /var/log/syslog | grep dhcpd
Then I discovered the cause of the server failure. I didn't declare a subnet mask for the listening interface. Here is a portion of my /etc/dhcp3/dhcpd.conf

Code: Select all

# /etc/dhcp3/dhcpd.conf
. . .
# Information about the network setup
subnet 192.168.1.0 netmask 255.255.255.0 {
	option routers 192.168.1.1;
	option broadcast-address 192.168.1.255;
	#option routers 192.168.100.1;
	#option broadcast-address 192.168.100.255;
. . .
Previously it had been subnet 192.168.100.0 and I changed it to subnet 192.168.1.0
Health in HEART, MIND, BODY and SOUL
mo0nykit
Post Reply