Re: how to assign an ip when assign a NIC or VF to the Virtual Machine?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, May 07, 2011 at 11:24:23PM +0800, guan qin wrote:
> So how can I assign an ip to the VM when assign the NIC or VF to the
> VM

It doesn't work like this.

Just like with real hardware, all the virtual hardware has is a MAC
address.  The (real or virtual) machine has to use some other method
to get an IP address and hostname after it has booted.  As with real
machines, either it does that using DHCP, or it has the IP address
hard-coded somewhere on disk.

The best solution is to create a separate DHCP service which assigns a
specific IP address to the known MAC address of the NIC/VF.  You can
get the MAC address using "virsh dumpxml".

Another solution would be to edit the guest before booting it and give
it the address you want it to have.  eg for RHEL and Fedora guests:

  guestfish -i -d MyGuest -- \
      upload - /etc/sysconfig/network-scripts/ifcfg-eth0 <<_EOF
  DEVICE=eth0
  IPADDR=192.168.1.2
  NETMASK=255.255.255.0
  NETWORK=192.168.1.0
  BROADCAST=192.168.1.255
  ONBOOT=yes
  _EOF

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]