Hi Serge, I was trying to prototype an *lxc-ip* script that takes a container's name and returns its ip address. Gary Poster spoke to you about the idea earlier this week. Today I've investigated ways to get the ip. This email summarizes my results. I'd really appreciate your comments and suggestions.
The first method taken into consideration was something like the following: 1. get the ip address of the dnsmasq virtual interface (checking for lxcbr0 and falling back to virbr0 if the former does not exist) 2. use host command or similar to query the name server for the given lxc name Using this method I am encountering dns cache problems, e.g. if you stop and then restart a container, dnsmasq returns the old ip address until the started instance obtains the new one. I've tried to clear the dns cache sending the HUP signal to the process, but it doesn't work. Another story could be (as discussed with Gary): 1. get the ip of the container, e.g. parsing lxc-ps and looking for the init process (lxc-info is another option but requires to be run as root, and I think a goal for this script is to run without root access). 2. use the ip to obtain the time the instance was started (using /proc/<pid>) 3. compare the lxc start time to the modification time of the leases file (rootfs/var/lib/dhcp3/dhclient.eth0.leases or similar) 4. if leases_time > start_time, get the ip from the leases otherwise, wait until we have a new entry in leases (or just exit with an error, or both, depending on a flag). I know this path is a little bit tricky, and I'd like to hear from you before starting to follow it. Thank you, -- Francesco Banconi -- Mailing list: https://launchpad.net/~yellow Post to : [email protected] Unsubscribe : https://launchpad.net/~yellow More help : https://help.launchpad.net/ListHelp

