[libvirt] how to assign an ip when assign a NIC or VF to the Virtual Machine?
guan qin
qinguan0619 at gmail.com
Sun May 8 02:56:54 UTC 2011
thanks for your reply !
The second solution you mentioned may be difficult , because when I assign
the ethX to the VM, the X in the 'ethX' is random (the 'X' in the host may
be different in the VM),I don't know it before I boot the VM . so maybe I
couldn't edit the guest correctly before booting VM.
The first solution :
The network card's MAC address I can know and assign an fixed IP in
advance, but for the VFs , before I create the VF by "modprobe
igb/ixgbe
max_vfs=num1,num2" ,I couldn't know the MAC address before either,the MAC
address generated randomly too.
So maybe I should edit the DHCP server configure file after creating the
VFs.
At first , I want to make the ethX name eth0, in that case, I can edit the
guest before booting the VM ,and I also can use the DHCP to dynamicly assign
an ip to the VM without editing the DHCP server configure file . but because
of unknowing the MAC address , I don't know how to use udev to bind the
netword card or VF to eth0 ?
I decided to first try the first solution you mentioned.
best regards,
qinguan
2011/5/8 Richard W.M. Jones <rjones at redhat.com>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110508/a73f8fd9/attachment-0001.htm>
More information about the libvir-list
mailing list