[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-users] Virtual Machine - Use the IP assigned through vif configuration
Hi, it is correct, that the vif configuration's ip=... option is mainly used internally by the vif-scripts, as it also resides in the network backend xenstore part. It seems to be possible to read it from the VM though, once the xenstore utilities are installed. I attached a small script for this. There are some pitfalls though: * It can only detect the IP, not netmasks or gateway addresses (because the ip=... option only stores the IP and there are no netmask=... etc. options) * xenstore utilities are usually not installed on a VM * I actually don't know if a VM can access its domain ID in a better way than this script does (iterating + test) - I'd appreciate some hints on how this can be optimized. What I actually did with some of my VMs and which works better is using the kernel ip=... command line parameter. It is documented at: https://www.mjmwired.net/kernel/Documentation/filesystems/nfs/nfsroot.txt Modern kernels however often don't follow this directive directly, if either the network card driver is a module or the corresponding kernel feature is disabled, which is done in some distribution kernels. The trick is, to use the parameter and to read it during bootup from /proc/cmdline. As it's even standardized by the kernel it is a good way to configure at least the primary interface. In Xen, it can be provided using either: extra = "ip=..." cmdline = "root=/dev/xvda1 ip=..." (newer Xen versions) A small example on reading it: sed -ne "s/.*ip=\([.0-9]\+\):\([.0-9]\+\):\([.0-9]\+\):\([.0-9]\+\):.*/\1 netmask \4 gateway \3/p" </proc/cmdline This information can also easily be processed in network scripts and does not require additional software in the domU. Cheers Felix > Hi, > >> I have a Xen environment with bridged networking and statically-assigned >> IPs. >> >> I am trying to set the virtual machines IPs through the XL Configuration >> File, using the vif = ['... ip=192.168.0.X ...'] statement. >> The problem is that I don't know what to put in the >> '/etc/network/interfaces' file to make the VM automatically get the >> Xen-assigned IP address. > As far as I know, the "ip"-option is only routed into the vif-script in > dom0 (or the network backend domU). Thus it is more or less unusable in > the domU. If I am wrong, please correct me, I'd love to use that option, > too! > > But I do think that not everything is lost. There is xenstore - this > might allow you to read the configured ip (and much more) from within > the domU, but I do not have any usable experience regarding this and it > might require a bit of scripting (and maybe changing permissions in the > dom0?) > Maybe that is a usable hint for you. > > Cheers > CRT > > _______________________________________________ > Xen-users mailing list > Xen-users@xxxxxxxxxxxxx > https://lists.xen.org/xen-users Attachment:
xenstore-vifip.sh _______________________________________________ Xen-users mailing list Xen-users@xxxxxxxxxxxxx https://lists.xen.org/xen-users
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |