VirtualBox

This is just a page for documenting some tricks I discovered while playing with VirtualBox.

Installing

Just download it from their site www.virtualbox.org and install it like this

dpkg -i name_of_the_downloaded_file.deb

Then start VirtualBox and install the guests. Instead of using a CDROM for installing guests, you can also use an ISO file as CDROM. This is faster.

VirtualBox comes with some kernel modules which need to be recompiled each time the kernel is upgraded. So if you upgrade the kernel, use this command to recompile the VirtualBox modules:

/etc/init.d/vboxdrv setup

VirtualBox works best with the "guest additions" installed. After installing the guest, start it up and use the option in the menu bar to install the guest additions.

Screen size

The graphics drivers of VirtualBox allow you to adjust the guest's screen size to the window size automatically. In KDE and Windows you can also set the screen size the same way you normally do. However in KDE I could not set the screen size to 1280x1024. If you would like to get certain fixed screen resolutions in a Ubuntu guest, add the following to the screen section of your /etc/X11/xorg.conf:

SubSection "Display"
Modes "1280x1024" "1152x864" "1024x768" "800x600"
EndSubSection

Cloning

You can copy a hard disk image of a virtual machine, by using this command to copy it:

VBoxManage clonevdi `pwd`/source.vdi `pwd`/dest.vdi

Note that absolute paths are required, hence the pwd commands.

The new vdi gets a unique (different) UUID. You can add the new image in the "virtual media manager", and create a new virtual machine which uses it.

When you cloned an Ubuntu guest, you may want to remove a file called /etc/udev/rules.d/70-persistent-net.rules in order to clear data about the old MAC address. Otherwise your new network card appears as eth1 instead of eth0.

Networking

By default Virtualbox uses a kind of NAT with a built-in DHCP server for the guests. I used "a kind of", because all guests actually use the same IP address. They cannot see each other and it is impossible to setup an incoming connection. You can access the host using 10.0.2.2. Instead of NAT you can also use "internal network". Now the guests can see each other, but they cannot access the outside world. Then there is "bridged networking" in which you can share the host interface. Disadvantage of that is the fact that the guest's IP-addresses are visible for the outside world. If you want NAT while keeping the ability to route incoming connections and the ability to communicate between guests, then use the following approach.

First install the software needed to create and setup tap interfaces:

aptitude install uml-utilities

Then create a script called tap to setup a tap interface:

#!/bin/sh

sysctl -w net.ipv4.conf.eth0.arp_ignore=1
sysctl -w net.ipv4.ip_forward=1
tunctl -t tap0 -u your_username
ifconfig tap0 192.168.1.1 netmask 255.255.255.0 up

exit 0

The first line prevents the host from responding to ARP requests which query IP addresses that happen to be used for internal networking. The second line enables routing. You can also put the sysctl settings in a file called /etc/sysctl.conf. The third line creates the tap interface. Replace your_username by your username. The fourth line sets up the tap interface.

Now we can setup NAT, using another script, called nat:

#!/bin/sh

iptables -P INPUT ACCEPT
iptables -F INPUT
iptables -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -P FORWARD DROP
iptables -F FORWARD
iptables -t nat -F

iptables -A FORWARD -i eth0 -o tap0 -m state --state ESTABLISHED,RELATED  -j ACCEPT
iptables -A FORWARD -i tap0 -o eth0 -j ACCEPT
iptables -A FORWARD -j LOG
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport 53 -i tap0 -j DNAT --to your_dns_server:53
iptables -t nat -A PREROUTING -p udp --dport 53 -i tap0 -j DNAT --to your_dns_server:53

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5800 -j DNAT \
   --to 192.168.1.100:5800
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5900 -j DNAT \
   --to 192.168.1.100:5900
iptables -A FORWARD -i eth0 -o tap0 -p tcp --dport 5800 -j ACCEPT
iptables -A FORWARD -i eth0 -o tap0 -p tcp --dport 5900 -j ACCEPT

exit 0

Replace your_dns_server by the IP address of your DNS server.

You may notice we forward ports 5800 and 5900. This is explained later, when we set up a remote desktop using a web browser.

In the VirtualBox network settings of your guest, use bridged network, and specify tap0 as its interface.

Start and setup the guest to use 192.168.1.100 as IP address and 192.168.1.1 as default gateway and DNS server (the latter being forwarded to the real DNS server).

Remote controlling your guests

You can SSH into your linux box and use the following command to startup a guest remotely:

VBoxManage startvm your_guest_name --type vrdp

Use VBoxManage (without arguments) to see what you can do on the command line.

Remote desktop using a web browser

You may have noticed that VirtualBox has a built-in RDP server, which you can enable and this works very well with the rdesktop client.

By default only one client can connect to the built-in RDP server at a given time. To allow simultaneous connections, use this command:

VBoxManage modifyvm "VM name" --vrdpmulticon on

You can also use the built-in RDP-server some guests (like Windows XP) provide. In that case you need to forward port 3389 in the same way we forwarded ports 5800 and 5900 earlier. The reason for forwarding 5800 and 5900 is the fact that there is no good Java based applet for connecting to RDP servers, so I use VNC instead. You may find some Java based RDP clients, like ProperJavaRDP and Elusiva, but those projects are dead and not working for me.

VNC uses port 5900. Port 5800 is used for the VNC web server.

There are many implementations of VNC, the best ones are RealVNC, TightVNC and UltraVNC. For Windows XP guests I use UltraVNC. Installation is pretty straightforward except for the display hook driver. After UltraVNC is installed, use the explorer to extract "c:\program files\UltraVNC\drivers.zip".  Then double click on "c:\program files\UltraVNC\drivers\driver\XP\install.bat".

Reboot the guest and enable the driver in the UltraVNC settings.

Now to use the Java client, just point a browser to http://your_host:5800/. You may notice the defaults are not good (restriction of 64 colors etc.). You can create the following HTML file, modify it to suit your needs and host it on a web server. This way you can create remote desktop hyperlinks to other VNC hosts as well.

<html>
        <head>
                <title>appletTitle</title>
        </head>
        <body>
                <applet code="VncViewer.class" width="1024" height="768">
                        <param name="archive" value="http://your_host:5800/VncViewer.jar">
                        <param name="host" value="your_host">
                        <param name="port" value="5900">
                        <param name="Open New Window" value="No">
                        <param name="Show Controls" value="No">
                        <param name="View only" value="No">
                        <param name="JPEG image quality" value="JPEG off">
                        <param name="Restricted colors" value="Full">
                </applet>
        </body>
</html>

Reference: http://forum.ultravnc.info/viewtopic.php?p=57961

USB devices

In Virtualbox there is a setting called USB filters, which determines which USB devices are available in guest systems running in Virtualbox. It's easiest to specify an empty filter which matches all USB devices. In the menu of the guest window you can enable (connect) and disable (disconnect) USB devices. If an USB device is greyed out, it might be a permissions problem. Check if the current user is a member of the vboxusers group with the groups command. If the user is not a member then add this user to the vboxusers group using the following command:

adduser <user> vboxusers

 

If you don't mind share more

If you don't mind share more like that. Read Significantly more

I wonderment why other

I wonderment why other professionals don't respond your website overmuch m happy I plant this. brian holm lawyer san diego

a debt of gratitude is in

a debt of gratitude is in order for the tips and information..i truly welcome it.. sell my house fast

Much thanks to you such a

Much thanks to you such a great amount for sharing this incredible blog.Very motivating and accommodating too.Hope you keep on sharing a greater amount of your ideas.I will love to peruse. mpf hk

Superb web journal! I

Superb web journal! I discovered it while surfing around on Yahoo News. Do you have any proposals on the most proficient method to get recorded in Yahoo News? I"ve been striving for some time yet I never appear to arrive! Value it. nonprofit job board

The data you have posted is

The data you have posted is extremely helpful. The locales you have alluded was great. A debt of gratitude is in order for sharing.. citation

There is so much in this

There is so much in this article that I would never have thought of on my own. Your content gives readers things to think about in an interesting way. Thank you for your clear information. Logout Facebook

Wow, cool post. I’d like to

Wow, cool post. I’d like to write like this too – taking time and real hard work to make a great article… but I put things off too much and never seem to get started. Thanks though. Foods That Cause Inflammation

I am all that much satisfied

I am all that much satisfied with the substance you have specified. I needed to thank you for this extraordinary article. autoradio gps 2017 web site website

This colourful tweed boucle

This colourful tweed boucle is a mix of fancy yarn in ivory, black and golden. metallic threads woven intricately during the fabric lend it a subtle glimmer. tweed boucle fabrics

The student bodies at the

The student bodies at the University of California and California community colleges average about 55 percent female -- slightly less than CSU's 59 percent. best photography studio in Katy

Great article

Are your daily drinking milk is healthy and germ-free? Get the best milk frother judge service which will inspect the source from the milk is produced.

Wow

We provide the best IETLS training read more about it which will provide you with the best quality methods and advice that will help you score good marks in IELTS exam.

On the off chance that you

On the off chance that you set out to make me think today; mission achieved! I truly like you"re composing style and how you express your thoughts. Much thanks to you. home

I truly inspired after read

I truly inspired after read this on account of some quality work and educational musings . I just wanna express profound gratitude for the author and want you to enjoy all that life has to offer for coming!. latest technology news

Is it alright to post a

Is it alright to post a portion of this on my site fundamentally present a hyperlink on this site page? http://www.casino-cash-bonus.com/

I truly thank you for the

I truly thank you for the profitable data on this incredible subject and anticipate more extraordinary posts. Much appreciated for getting a charge out of this magnificence article with me. I am valuing it all that much! Anticipating another extraordinary article. Good fortunes to the creator! All the best! software development costa rica

I as of late ran over your

I as of late ran over your website and have been perusing along. I thought I would leave my first remark. I don't realize what to say with the exception of that I have delighted in perusing. Decent blog. I will continue going to this web journal regularly. curso de educação a distância

I truly like your thoughts on

I truly like your thoughts on the issue. I now have an unmistakable thought on what this matter is about.. Health Benefits of Garlic

Cool stuff you have and you

Cool stuff you have and you keep redesign every one of us. Friv 4

I as of late discovered

I as of late discovered numerous helpful data in your site particularly this site page. Among the loads of remarks on your articles. A debt of gratitude is in order for sharing. Search Engine Optimization Phoenix

That's a great position you

That's a great position you folks have been carrying out there. showbox for android

Its an incredible delight

Its an incredible delight perusing your post.Its brimming with data I am searching for and I want to post a remark that "The substance of your post is wonderful" Great work. wall decals

This is an extraordinary

This is an extraordinary article much obliged for sharing this enlightening data. I will visit your website consistently for some most recent post. I will visit your web journal consistently for Some most recent post. voyance de qualité

Much appreciated such a great

Much appreciated such a great amount for this data. I need to tell you I agree on a few of the focuses you make here and others might require some further survey, however I can see your perspective. io games

The student bodies at the

The student bodies at the University of California and California community colleges average about 55 percent female -- slightly less than CSU's 59 percent. How To Get a Loan With No Credit

Much obliged to you for some

Much obliged to you for some other educational web journal. Where else would I be able to understand that sort of data written in such a perfect means? I have a mission that I"m a little while ago chipping away at, and I have been at the post for such data. Thomas Frank Paquin

If it's not too much trouble

If it's not too much trouble proceed with this incredible work and I anticipate a greater amount of your wonderful blog entries. cheapest color copies print

They did good work and aimed

They did good work and aimed to provide me with the highest level of customer service to make sure I was a satisfied customer. Glass repair

Appreciating the time and

Appreciating the time and exertion you put into your web journal and definite data you offer!.. bungalow house plans

I can set up my new thought

I can set up my new thought from this post. It gives inside and out data. A debt of gratitude is in order for this profitable data for all,.. invokana amputations

I can set up my new thought

I can set up my new thought from this post. It gives inside and out data. A debt of gratitude is in order for this profitable data for all,.. invokana amputations

Thankyou for this wondrous

Thankyou for this wondrous post, I am happy I watched this site on yippee. Windows Files

Exceptionally helpful post.

Exceptionally helpful post. This is my first time i visit here. I discovered such a variety of intriguing stuff in your web journal particularly its examination. Truly its incredible article. Keep it up. Kadıköy Nakliyat

Faser Valley fencing

Faser Valley fencing contractor with in house welding shop and best prices on high quality chainlink fencing for residential and commercial fencing There contractors out there but Lencing has won t service in the Fraser Vally several times. Chain link fencing contractors

You make such a variety of

You make such a variety of extraordinary focuses here that I read your article several times. Your perspectives are as per my own generally. This is extraordinary substance for your perusers. air duct cleaning ftstewartga

A place for developers,

A place for developers, builders, and home owners to buy building products for the commercial and or residential build or Reno project Builders Haus is a place for vendors to reach a further reach to wholesale products and make greater customer reach. laminate flooring

Incredible data on your

Incredible data on your website, thank you for setting aside an ideal opportunity to impart to us. Stunning understanding you have on this current, it's pleasant to discover a site that points of interest such a great amount of data about distinctive specialists. SNZ HB 167-2006

I might want to say this web

I might want to say this web journal truly persuaded me to do it! Much obliged, great post. Remove Tar and Nicotine

Awesome online journal! Do

Awesome online journal! Do you have any tips and indications for trying authors? I'm wanting to begin my own site soon yet I'm somewhat lost on everything. Would you propose beginning with a free stage like WordPress or go for a paid choice? There are such a large number of choices out there that I'm totally overpowered .. Any proposals? Much obliged! Mobdro Online TV

I high value this post. It's

I high value this post. It's elusive the great from the terrible now and then, however I think you've nailed it! would you brain overhauling your web journal with more data? apartmets in Hoan Kiem for rent

This article was written by a

This article was written by a real thinking writer. I agree many of the with the solid points made by the writer. I’ll be back. Laptop Repair Colorado Springs

Thank you for another great

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information. Language of Desire

This substance is composed

This substance is composed exceptionally well. Your utilization of organizing when mentioning your focuses makes your objective facts clear and straightforward. Much obliged to you. proplex

Much obliged to you so much

Much obliged to you so much Love your site.. Lean Belly Breakthrough

You have made an awesome

You have made an awesome showing on this article. It's exceptionally lucid and exceedingly astute. You have even figured out how to make it reasonable and simple to peruse. You have some genuine written work ability. Much thanks to you. Cheap 3d print places near me

I have read a few of the

I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favorites blog site list and will be checking back soon. Please check out my site as well and let me know what you think. best refrigerator repair Denver I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing.

Whilst a few dental test

Whilst a few dental test americaare annual, different can be month-to-month or quarterly. You can not come up with the money for to disregard such check americaeven with the escalating costs of dental care check this out.

It is an incredible site..

It is an incredible site.. The Design looks great.. Continue working like that!. Deals

I might want to thank you for

I might want to thank you for the endeavors you have made in composing this article. I am trusting the same best work from you later on too. Much appreciated... chelsea injuries 2017-18