Fix host-only adapter Virtualbox can’t dhclient and get ip address


I use Ubuntu 11.10 as Host and Ubuntu 11.04 as Guest on Virtualbox 4.1.4. I running VM using Vagrant and Virtualbox (for Desktop version). When i set host-only adapter, i got issue that my network card (eth1) can’t get IP address.

This is weird which i have this work before. Switch on-off on network card doesn’t fix this problem. Also, when i delete “/etc/udev/rules.d/70-persistent-net.rules”, the problem still occured.

After diving for a while, i gota the solution.

1. Configure Host-adapter
Go to File -> Preferences -> Network. If you don’t have vboxnet0, you should create new one. Then, we need to configure this host-only adapter to available for static and dhcp ip. Edit this adapter :
For example, i use 33.33.33.1 as my host IP address.

On Adapter tab :

1
2
3
4
IPv4 address = 33.33.33.1
IPv4 Network Mask = 255.255.255.0
IPv6 Address = …
IPv6 Network mask length = 64

On DHCP Server tab :
Check “Enable Server” and configure :

1
2
3
4
Server Address = 33.33.33.1
Server Mask = 255.255.255.0
Lower Address Bound = 33.33.33.10
Upper Address Bound = 33.33.33.100

2. Edit network interfaces Guest / VM
Edit /etc/network/interfaces :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
#iface eth0 inet dhcp

# The primary network interface
auto eth1
#iface eth1 inet dhcp

3. Reset Network Card
by deleting “/etc/udev/rules.d/70-persistent-net.rules” :

1
sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules

Reboot your VM and you should have host-only network adapter have IP address on range 33.33.33.10 – 33.33.33.100.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.