Thank you, Ben. I have just searched again for similar questions, and found
what I think is the most "natural" solution:
Add this line to /etc/dhcp/dhclient.conf on the host:
prepend domain-name-servers 10.0.3.1;
Then run "service networking restart", and I can log into the guest with "ssh
ubuntu@guest1" or use "nslookup guest1".
HTH
Alan
________________________________
From: Ben Butler-Cole <b...@bridesmere.com>
To: Alan McDuff <alan.mcd...@yahoo.com>
Cc: Marko Anastasov <marko.anasta...@gmail.com>;
"lxc-users@lists.sourceforge.net" <lxc-users@lists.sourceforge.net>
Sent: Monday, January 7, 2013 11:11 AM
Subject: Re: [Lxc-users] retrieve guest container's ip address
On 5 January 2013 12:29, Alan McDuff <alan.mcd...@yahoo.com> wrote:
>If you paste the .lxc part from
>http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/
> into your ~/.ssh/config >and start the container, then you should be able to
>ssh with "ssh ubu...@guest1.lxc".
>
>Thanks, but this doesn't look like a clean setup to me. If there is no better
>solution, I will write a post-lxc-create script that appends "$(host
>$guestname 10.0.3.1) $guestname" to /etc/hosts.
>
I think that writing the address into /etc/hosts may cause you problems
eventually because it will get out of date when you remove containers and
potentially recycle addresses.
Stephane's solution has the advantage that it looks up the address dynamically
when you need it. I really like the idea of putting the look-up into
~/.ssh/config, especially because it allows you to other useful things like
turning off some security checking and setting the username.
If you don't like that solution because of the non-locality, you might prefer
to write a small script, say `lxc-ssh`:
$1=container
ssh $(host $container 10.0.3.1 | tail -1 | awk '{print $NF}')
-Ben
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122412
_______________________________________________
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users