Skip to main content

Fixing VBox guest lossing networking connection

When playing around with Virtual Box guests running Linux, the network connection my get lost on Debian Etch when the virtual interface's MAC changes. This is due to the fact that this version of linux is using udev and fortunately udev detects changes to MAC address. So basically, each new network interface with new MAC address gets its new ethx network interface device name. In my case, I got 3 ethx's already so I need to get rid of the unnecessary interfaces. As a root do this:
$: su
#: cd /etc/udev/rules.d
#: mkdir ~/bak
#: cp zxx_persistent-net-generator.rules ~/bak
#: rm zxx_persistent-net-generator.rules
#: /etc/init.d/udev stop
#: /etc/init.d/udev start
Note that we make a backup of the file just in case we need to go back. Also, for zxx_persistent-net-generator.rules, xx is any two digit number. So just go check the directory for a file that resembels *_persistent-net-generator.rules. Now to prevent udev to generate new interface for every new MAC address for Virtual Box virtual interface, do make the following changes:
#: nano -w /etc/udev/persistent-net-generator.rules
Then ensure that you have the line to ingore MAC address from Virtual Box virtual network interface:
# These rules generate rules to keep network interface names unchanged
# across reboots write them to /etc/udev/rules.d/z25_persistent-net.rules.
#
# The default name for this file is z45_persistent-net-generator.rules.

ACTION!="add",    GOTO="persistent_net_generator_end"
SUBSYSTEM!="net",   GOTO="persistent_net_generator_end"

# ignore the interface if a name has already been set
NAME=="?*",    GOTO="persistent_net_generator_end"

# ignore "secondary" raw interfaces of the madwifi driver
KERNEL=="ath*", ATTRS{type}=="802", GOTO="persistent_net_generator_end"

# provide nice comments for the generated rules
SUBSYSTEMS=="pci", \
ENV{COMMENT}="PCI device $attr{vendor}:$attr{device}"
SUBSYSTEMS=="usb", \
ENV{COMMENT}="USB device $attr{idVendor}:$attr{idProduct}"
SUBSYSTEMS=="ieee1394", \
ENV{COMMENT}="Firewire device $attr{host_id}"
SUBSYSTEMS=="xen", \
ENV{COMMENT}="Xen virtual device"
ENV{COMMENT}=="", \
ENV{COMMENT}="Unknown $env{SUBSYSTEM} device ($env{DEVPATH})"
ATTRS{driver}=="?*", \
ENV{COMMENT}="$env{COMMENT} ($attr{driver})"
#Ignore Virtual Box virtual network interface
ATTR{address}=="08:00:27:*", GOTO="persistent_net_generator_end"

# ignore interfaces without a driver link like bridges and VLANs
KERNEL=="eth*|ath*|wlan*|ra*|sta*", DRIVERS=="?*",\
IMPORT{program}="write_net_rules $attr{address}"

ENV{INTERFACE_NEW}=="?*", NAME="$env{INTERFACE_NEW}"

LABEL="persistent_net_generator_end"
Then delete /etc/udev/rules.d/zxx_persistent-net-generator.rules. In Debian Etch, default xx value is 25 but once you re-generate new rule it defaults xx to 45. Now once you restart udev or reboot the machine you should have a persistent interface name for Virtual Box virtual interface. A word of caution though. If you add another interface this may cause problem as udev might not assign new network interface for the additional NIC card since we have created an exception. So you might opt to use the first method of just regenerating the rules by deleting /etc/udev/rules.d/zxx_persistent-net-generator.rules and restarting udev or rebooting the machine.

References: http://forums.virtualbox.org/viewtopic.php?t=1616

Enjoy!

~TechnoS

Comments

Popular posts from this blog

Error! Could not locate dkms.conf file install VirtualBox 4.1.8 on Ubuntu 11.10

Tried to update my Ubuntu host today and it did pickup that new version of VirtualBox is available (4.1.8). All other packages installed properly except that VirtualBox installation was complaining about missing dkms.conf file, see error message below. $: sudo /etc/init.d/vboxdrv setup * Stopping VirtualBox kernel modules [ OK ] * Uninstalling old VirtualBox DKMS kernel modules Error! Could not locate dkms.conf file. File: does not exist. [ OK ] * Trying to register the VirtualBox kernel modules using DKMS [ OK ] * Starting VirtualBox kernel modules [ OK ] Though it looks like installation was fine but I am concerned about its effects to VirtualBox functionality. To fix this, do: $: cd /var/lib/dkms/vboxhost $: sudo rm -r 4.1.4 $: sudo /etc/init.d/vboxdrv setup Of course you have to re

The following add-ins could not be started MonoDevelop.GnomePlatform

Installing MonoDevelop in OpenSUSE 12.2 from its repository was very easy. When running it for the first time though I got the message: The following add-ins could not be started: The root of the trace shows MonoDevelop.GnomePlatform,2.8 A quick search shows that MonoDevelop depends on libgnomeui . This should have been part of dependencies when installing the application but well.... Below is the screen shot of the error message. References: http://software.1713.n2.nabble.com/MonoDevelop-and-openSUSE-12-1-td7462957.html [2013/04/09] - Same issue observed in OpenSUSE 12.3 and also the same fix. [2014/11/02] - Same issue observed in OpenSUSE 13.3, mondevelop 3.0.6 and the same fix.