[Solved] Bridged Networking Failing

Discussions about using Linux guests in VirtualBox.
Post Reply
Sylvia Else
Posts: 7
Joined: 5. Mar 2018, 04:48

[Solved] Bridged Networking Failing

Post by Sylvia Else »

I have determined that there is a error in the Linux kernel driver for varous Intel Pro/1000 variants used by default by VirtualBox for some types of guest. This interacts with VirtualBox such that in certain situations the guest will not be able to access through the bridged network. This happens when there are broadcast packets in the network around the time when the interface is brought up. Since broadcast packets are part of the way the network functions, this can cause occasional failures when bringing up any guest with bridged networking. The user's most likely response would be to try again, and if it works, think nothing more of it.

However, it becomes more likely to be point of inevitability if there's a machine on the network that's trying to contact another that's not responding, because it will keep sending out broadcast packets. In my case, it's my printer that's down for some reason.

I'll submit proposed changes to the kernel driver to fix the problem, and also to VirtualBox to sidestep it.

In the mean time, people experiencing diffulties could try the other network interace types. If all else fails, or if it just seems simpler, I've created a hack to get around it - note LIMITATIONS - which should work unchanged on systemd based systems. Some modification may be required otherwise.

LIMITATIONS: This hack will only work if the guest has manually assigned IP address and default route. If it's configured to use DHCP to get either, or both, of these, then the hack will not work.

Put the following into a file called setup.sh

Code: Select all

#----- Start of setup.h
cat >/etc/vbxhack.sh <<'END'
while true; do
    # Wait until a default route appears.
    while true; do
        ip -o route show | grep default >/tmp/device
        if [ -s /tmp/device ]; then break; fi
        usleep 100000
    done
    # Got a default route, so get the gatewake and interface
    def=`sed -e "s/^default via \\([^ ]*\\).*/\\1/" /tmp/device`
    dev=`sed "-e s/^default via [^ ]* dev \\([^ ]*\\).*/\\1/" /tmp/device`
    # If we can ping the gateway, then we're done.
    if ping -c 2 ${def} >/dev/null 2>/dev/null; then break; fi
    # Save routes, take the interface down and up, and restore routes.
    ip route save >/tmp/routesave
    ip link set ${dev} down
    ip link set ${dev} up
    # Restore the routes will always give an error, which does not matter.
    ip route restore </tmp/routesave 2>/dev/null
done
END
if [ ! -s /etc/rc.d/rc.local ]; then
    echo "#!/bin/bash" >/etc/rc.d/rc.local
fi
chmod +x /etc/rc.d/rc.local
echo "sh /etc/vbxhack.sh &" >>/etc/rc.d/rc.local
#--- End of setup.h
Then do

Code: Select all

sudo sh setup.sh
Restart the machine, and with luck you'll have a working bridged network.
Last edited by socratis on 11. Mar 2018, 11:29, edited 1 time in total.
Reason: Enclosed the information in [code] tag for better readability
Post Reply