KVM - The Linux Kernel-Based Virtual Machine
News, Blogs and Resources on the Linux (KVM) Kernel-Based Virtual Machine

Not getting automatic IP address (NAT)

6 replies [Last post]
nielsb
Offline
Joined: Sep 14 2008
Points: 0

So, I have just switched to KVM for my virtualization needs, and I like it! I have created a couple of VM's (Windows Server 2008), running on my ArchLinux host.

So far, so good apart from the issue that when I start one or two particular VM's they are not getting an IP address from the built-in NAT (10.0.2.x). What's strange is that when I set them up, it worked OK - and I haven't changed anything since; other VM's just work fine, with the exactly same setup.

This is the way I did it (if anyone can spot something particular):
1. I created a new VM (Windows Server 2008) from scratch, let's call it A.img. When I booted up the VM for the first time I received 10.0.2.15 (I assume that's the default KVM NAT "server"), and I could connect to my host and the internet.
2. I then did some installations etc on the guest (A.img), rebooted a couple of times and it worked fine.
3. I copied the VM image to another name (B.img), booted it up and the networking worked fine (received the same 10.0.2.15 address).
4. Made some more installations on B.img, a cuple of reboots and all was OK.
5. Copied B.img to C.img, booted up C.img and networking was OK (10.0.2.15).
6. Went back to A.img, booted it up, and now I'm not getting the 10.0.2.15 (the other VM's - B, C, are not running now), but an address in the 169 range (the address you get in Windows when you can't get an IP from a DHCP server). If I start up B or C all works OK.
7. If I manually assign a 10.0.2.x address to A.img all works.

So, is this something I have done wrong (most likely), or is it a bug, or ...???

Thanks!

Niels

Haydn Solomon
Offline
Joined: Mar 7 2008
Points: 458
Re: dhcp

Nielsb,

This may or may not work but you could probably try restarting your dnsmasq service. The script is usually located at /etc/rc.d/init.d/dnsmasq

Also what command line are you using to start your machine?

nielsb
Offline
Joined: Sep 14 2008
Points: 0
Hi Haydn, My command line is

Hi Haydn,
My command line is something like:
qemu-kvm -m 2048 -std-vga -localtime -hda A.img

after having posted my the original question I did some more googling and came across "-net user", I'll try that next time it happens.

As for dnsmasq; AFAIK/understand I wouldn't need it if I just do user mode networking (10.0.2.x), and I do not have it installed either on my host.

Thanks!!

Niels

Haydn Solomon
Offline
Joined: Mar 7 2008
Points: 458
Re: command line

Hi Neilsb

You're right, dnsmasq is not needed for userspace. The -net user should be default but try it and let us know.

nielsb
Offline
Joined: Sep 14 2008
Points: 0
Hi Haydn, I'll let you know

Hi Haydn,

I'll let you know if it happens again if "-net user" would help.

Thanks!!

Nielsfomuma

Anonymous
I have the same problem...

I have a similar issue on my Arch Linux laptop. When I'm connected to my wireless network at home, the internal NAT system with DHCP in QEMU works fine, but when I'm at work and connected to their wireless network, the virtual machine doesn't receive a IP-address from QEMU. It's extremely weird.

I haven't had the time to debug this further, it must be a bug somewhere...in qemu or in the kernel perhaps :-/

Kenni

jpa (not verified)
Solution

I ran into the same problem - Windows 2008 networking using RTL8139C drivers does not get IP address through DHCP.

Messing around with the options in Windows, I ran into the following:
In Control Panel -> Network Connections -> Properties of the adapter, Configure-button, Advanced-tab:
"Network Address" had a default setting of "Not present".

Setting a bogus MAC-address to that field fixed the problem.

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.