r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

How To: Make VirtualBox Use Your Router’s DHCP to get an IP Address in Linux

r3dux | September 5, 2009

Update: The method below for getting a virtualbox IP from your DHCP works (in linux) – but it turns out there’s an easier way (kindly pointed out by Mike in the comments below). You can just change your VirtualBox network settings from NAT to Bridged Adapter and point it at eth0/wlan0 or whichever connection is being used for networking. Then, optionally, you can configure the MAC address of the bridged adapter and set your router to assign a specific IP to a specific bridged adapter. Also, the built-in Bridged Adapter method works to deploy solutions from XNA Game Studio to my Xbox 360, so I’m rapt! Thanks, Mike!

VirtualBox Bridged Adapter Settings

Note: The below bit is for linux only, the above method should work on any host OS!


VirtualBox is an awesome bit of kit and I <3 it long time ten-dorrah.

But by default when your virtual copy of Windows/Linux/Solaris/Whatever grabs an IP address, it does so through NAT, and at version 3.0.4, this means it gives us a default Category A network address (i.e. 10.x.y.z).

It’s a working cat-A address, as in it’s fully functional and can talk to the Internet and all that, but sometimes life is a lot easier if you have an IP in the same range as the DHCP pool your router is dishing out. For example, my lappy is 192.168.1.101 internally, my Wii might be 192.168.1.102, the NAS .103 etc, so I want my virtualboxen to take addresses like .104, .105 and such.

I’m doing this to bridge my wireless connection on wlan0, if you’re bridging an ethernet connection substitute eth0 or whatever connection as necessary.

Also, to perform the bridging using this method, you’ll need some tools (feel free to sudo apt-get install NAME-OF-TOOL as necessary):
- 1.) uml-utilities
- 2.) parprouted
- 3.) bcrelay

Now, with that lot installed, run the following commands (provided here in bash script form):

#!/bin/bash
 
# To use this script you will need the following utilities installed:
# 1.) uml-utilities 2.) parprouted  3.) bcrelay
# sudo apt-get install 'em
 
# Enable IP forwarding
sudo sysctl net.ipv4.ip_forward=1
 
# Create a TAP as your current logged in user (replace with -u YOUR-USER-NAME if you want...)
sudo tunctl -u $USER
 
# Tell tap0 to respond to ARP (Address Resolution Protocal) packets 
sudo sysctl net.ipv4.conf.tap0.proxy_arp=1
 
# Give your TAP (tap0) an IP address and enable it (make sure the IP address is OUTSIDE the DHCP range on your router)
sudo ip addr add 192.168.1.150/32 dev tap0
sudo ip link set tap0 up
 
# Run parprouted and make it add routes automatically for wlan0 and tap0 as needed
# Make the command "parprouted -d wlan0 tap0" to display routes added and additional info. No sudo necc. for this one.
parprouted wlan0 tap0
 
# Use bcrelay on your net connection and TAP to "rewrite the layer-2 header and forward broadcast messages between network interfaces"
# The "-d" in this instance MAKES bcrelay work as a daemon. Need to sudo this or it doesn't work.
sudo bcrelay -d -i tap0 -o wlan0

Now, fire up VirtualBox and for your machine of choice change the network selection from NAT to tap0 as shown:

VirtualBox-tap0

Then boot up your virtual machine and check the IP:

VirtualBox-bridged-IP

Great. Super. Smashing. =D

Note: The entire reason I wanted to grab an IP from the router was so my virtual copy of XP could be on the same network as my XBox 360, so I could deploy games to it through XNA Studio 3.1, however XNA Studio is very fussy about timing when it comes to registering the 360, and although it can see the 360 using the bridge, and it tries to connect, it times out before it can fully establish a connection. I guess I’ll have to go with an IP routes method of bridging if I want it to work for that purpose, but as yet I haven’t quite figured it all out. Will keep trying when I have time, or if you know a way, feel free to call me technically incompetent and sling a solution in the comments! Cheers!

Comments
13 Comments »
Categories
How-To, Linux
Tags
bcrelay, Bridge, DHCP, eth0, How-To, IP, Linux, NAT, network, networking, parprouted, tap0, VirtualBox, Wireless, wlan0
Comments rss Comments rss
Trackback Trackback

How To: Fix Wireless Connection Drops on the Intel 4965 Chipset in Jaunty 9.04

r3dux | April 29, 2009

There’s a problem with the iwlagn wireless driver that ships with Jaunty by default, and you’ll find that when wireless connectivity drops you’ll have errors like these in your dmesg log:

[126774.231915] iwlagn: Microcode SW error detected. Restarting 0×2000000.
[126774.252811] iwlagn: MAC is in deep sleep!

Now, you can reset the connection easily enough with sudo ifdown wlan0 && sudo ifup wlan0, but thankfully the fix is already in the updated version of the iwglan driver in backports, so just go:

sudo apt-get install linux-backports-modules-jaunty

A swift reboot later and wireless ain’t gonna drop out on you any time soon – hurrah!

Comments
2 Comments »
Categories
How-To, Linux
Tags
backports, iwlagn, Wireless
Comments rss Comments rss
Trackback Trackback

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Film Flash GLSL Gnome Hack How-To install Jaunty Java Kinect Linkage Linux Mash-Up Microsoft Motion OpenGL Particle Photoshop Problem PS3 Remix Remove Retro script Slides Sound Systems Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“Never argue with an idiot. They drag you down to their level and then beat you with experience...”

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox