2

I make virtual environment with Ubuntu+KVM.

It is the following constitution, but it is lent IP (192.168.1.2) ubuntu02 by DHCPD, and the same IP seems to be lent to ubuntu03

router/dhcpd - ubuntu01(host) 192.168.1.100
             - ubuntu02(kvm)  192.168.1.2
             - ubuntu03(kvm)  192.168.1.2?

What's wrong?

ubuntu01:/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
  address 192.168.1.100
  network 192.168.1.0
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.1
  bridge_ports eth0
  bridge_fd 9
  bridge_hello 2
  bridge_maxage 12
  bridge_stp off

ubuntu0[23]:/etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

I usually execute this shell command sudo kvm -hda ubuntu.img -m 512 -localtime -net nic,model=pcnet -net tap,script=/etc/qemu-ifup -daemonize -nographic

/etc/qemu-ifup

#!/bin/sh
#sudo -p "Password for $0:" /sbin/ifconfig $1 172.20.0.1
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
sudo /usr/sbin/brctl addif br0 $1
sleep 2

2 Answers 2

6

LapTop006 is correct. Both of your VMs have the same MAC address causing your DHCP server to assign the same IP address to both VMs.

When you start each virtual machine, you will need to add the command line option

-net nic,macaddr=aa:bb:cc:dd:ee:ff

so that each VM receives a unique MAC address. Substitute aa:bb:cc:dd:ee:ff for any valid MAC address that's not being used in your network. I just use 00:00:00:00:00:01 for the first VM, 00:00:00:00:00:02 for the second VM and so on.

I ended up creating a separate shell script to start each VM. For example, to start my OpenSolaris VM I use ...

#!/bin/bash

vdeq kvm \
    -localtime \
    -hda /data/kvm/opensolaris_hda.raw \
    -hdb /data/kvm/opensolaris_hdb.raw \
    -hdd /data/kvm/opensolaris_hdd.raw \
    -m 1024 \
    -no-acpi \
    -usb \
    -usbdevice tablet \
    -net nic,macaddr=00:00:00:00:00:04 \
    -net tap,script=/etc/kvm/kvm-ifup \
    -cdrom /usr/local/src/CD/osol-0811.iso \
    -boot c
2

Are they sharing MAC addresses?

Check the results of ifconfig in both vm's.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .