<div dir="ltr"><br><div class="gmail_extra">On Fri, Dec 28, 2012 at 1:57 PM, Stéphane Graber <span dir="ltr"><<a href="mailto:stgraber@ubuntu.com" target="_blank">stgraber@ubuntu.com</a>></span> wrote:<br><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On 12/28/2012 01:20 PM, Marko Anastasov wrote:<br>


><br>
> On Dec 28, 2012, at 11:47 , Stéphane Graber <<a href="mailto:stgraber@ubuntu.com">stgraber@ubuntu.com</a>> wrote:<br>
><br>
>> On 12/28/2012 10:27 AM, Marko Anastasov wrote:<br>
>>> Hello,<br>
>>><br>
>>> What is the best way to broadcast container's hostname to host? I want to be able to ssh from host into the container using its hostname as handle, instead of an IP address.<br>
>>><br>
>>> I'm using the default template in Ubuntu 12.04. I have made a container template that I want to reuse. My first attempt was to install avahi-daemon on host and container, replace hostname in container config, fstab, /etc/hosts, /etc/hostname and dhclient.conf with some unique id. This worked in VirtualBox, but for some reason not on a real machine.<br>


>>><br>
>>> Thanks,<br>
>>> Marko<br>
>><br>
>> Not exactly an answer to your question, but should be an answer to your<br>
>> problem anyway:<br>
>> <a href="http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/" target="_blank">http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/</a><br>


><br>
> Hi Stéphane,<br>
><br>
> I should note that I'm working with a server installation of 12.04, and packages dnsmasq and resolvconf are actually not installed by default. I've added them but I'm not sure what's next. So I think I'm missing some configuration that you assume on your blog.<br>


<br>
</div>LXC in Ubuntu comes with dnsmasq-base and resolvconf was introduced by<br>
default by me in Ubuntu 12.04, so you have it for sure or you're not<br>
using a supported Ubuntu installation (resolvconf is part of<br>
ubuntu-minimal).<br>
<div class="im"><br>
><br>
> Eg output of host $(echo %h | sed "s/\\.lxc//g") 10.0.3.1 is<br>
><br>
> Using domain server:<br>
> Name: 10.0.3.1<br>
> Address: 10.0.3.1#53<br>
> Aliases:<br>
><br>
> Host %h not found: 3(NXDOMAIN)<br>
<br>
</div>That's because once put in your ssh config, the %h will be replaced by<br>
the name of your container.<br>
<br>
Try "host <container name> 10.0.3.1", that'll return the IP address of<br>
your container as long as it's using DHCP for its IP configuration.<br>
<br></blockquote><div><br></div><div style>Thanks for your help Stéphane. This all works. A quick recap:</div><div style><br></div><div style> - no additional packages aside from dnsmasq-base and resolvconf on host are needed</div>

<div style> - "host container-name 10.0.3.1" is a way of getting the container's IP address; Stéphane's blog post shows a clever way of using that in ssh config to address containers by their name</div>
<div style>
<br></div><div style>I guess the next step forward would be to have the container name resolveable as a network name system-wide (again, having more knowledge about the networking stack would help). For my purposes it isn't absolutely necessary though.</div>

<div style><br></div><div style>Marko</div></div></div></div>