[Lxc-users] How long the dhcp lease lasts

Robin Monjo robin.monjo at applidget.com
Mon Apr 22 20:58:43 UTC 2013


Thank you for your answer.
I want to have the hostname and ip written in the /etc/hosts file so I can access them directly using their hostname and not their ip. For example, I'd like to ping the hostname rather than the ip.

I will document myself on dnsmasq to get a better understanding of everything.


On Apr 22, 2013, at 10:48 PM, Michael H. Warfield <mhw at WittsEnd.com> wrote:

> On Mon, 2013-04-22 at 21:59 +0200, Robin Monjo wrote:
>> Hello everyone,
>> 
>> Using the default config, containers will have their IP attributed by
>> the dnsmasq service. I'd like to write in the '/etc/hosts' file of the
>> host system the hostname and the corresponding IP address of each
>> container I start.
> 
> Why?  If you're using dnsmasq, it's in the DNS cache of the dnsmasq
> server.  That's its purpose in life, to act as a DNS caching service.
> Why do you need it in /etc/hosts when you've already got in in DNS?
> 
>> I will then use this hostname in an iptable rules for port forwarding.
>> But what if dnsmasq change an IP at the end of the lease ?
> 
>> So the question is: how long an IP given by dnsmasq will last ?
> 
> What is your lease expiration configured for?  I've used anything for a
> few hours (high turnover large WiFi sites) to several days to carry over
> a weekend along with static leases for servers and "permanent" devices.
> It depends on what you've configured it for.
> 
>> May I see one of my container have its IP changed ?
> 
> Maybe.  Depends on what you've configured it for.  I'm not so sure about
> dnsmasq acting as the dhcp server (which is what you are talking about)
> but dhcpd will notify you of things like this.  Most notably, you will
> get deletes on old name/addresses and adds for new name/addresses both
> forward and reverse, but it's all configuration driven.
> 
>> Any ways to have the dnsmasq table synced with the /etc/hosts file
>> (container's host side) ?
> 
> Again...  Why?  Use the DNS cache in dnsmasq.  You have no need to refer
> to /etc/hosts at all.
> 
>> Kind regards
> 
> Regards,
> Mike
> -- 
> Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
>   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
>   NIC whois: MHW9          | An optimist believes we live in the best of all
> PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!





More information about the lxc-users mailing list