Re: [Lxc-users] Networking between host and container

2013-01-05 Thread Marko Anastasov
On Fri, Dec 28, 2012 at 1:57 PM, Stéphane Graber stgra...@ubuntu.comwrote:

 On 12/28/2012 01:20 PM, Marko Anastasov wrote:
 
  On Dec 28, 2012, at 11:47 , Stéphane Graber stgra...@ubuntu.com wrote:
 
  On 12/28/2012 10:27 AM, Marko Anastasov wrote:
  Hello,
 
  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.
 
  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.
 
  Thanks,
  Marko
 
  Not exactly an answer to your question, but should be an answer to your
  problem anyway:
 
 http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/
 
  Hi Stéphane,
 
  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.

 LXC in Ubuntu comes with dnsmasq-base and resolvconf was introduced by
 default by me in Ubuntu 12.04, so you have it for sure or you're not
 using a supported Ubuntu installation (resolvconf is part of
 ubuntu-minimal).

 
  Eg output of host $(echo %h | sed s/\\.lxc//g) 10.0.3.1 is
 
  Using domain server:
  Name: 10.0.3.1
  Address: 10.0.3.1#53
  Aliases:
 
  Host %h not found: 3(NXDOMAIN)

 That's because once put in your ssh config, the %h will be replaced by
 the name of your container.

 Try host container name 10.0.3.1, that'll return the IP address of
 your container as long as it's using DHCP for its IP configuration.


Thanks for your help Stéphane. This all works. A quick recap:

 - no additional packages aside from dnsmasq-base and resolvconf on host
are needed
 - 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

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.

Marko
--
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_122912___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


[Lxc-users] Networking between host and container

2012-12-28 Thread Marko Anastasov
Hello,

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.

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.

Thanks,
Marko
--
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of 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_122812
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] Networking between host and container

2012-12-28 Thread Stéphane Graber
On 12/28/2012 10:27 AM, Marko Anastasov wrote:
 Hello,
 
 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.
 
 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.
 
 Thanks,
 Marko

Not exactly an answer to your question, but should be an answer to your
problem anyway:
http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of 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_122812___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] Networking between host and container

2012-12-28 Thread Rob van der Hoeven

 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.
 
 I'm using the default template in Ubuntu 12.04. 
 I have made a container template that I want to reuse.

My setup uses the container name as its handle.
If I create a container like this: 

cd /var/lib/lxc
mkdir test
/usr/lib/lxc/templates/lxc-debian-box -n test -p /var/lib/lxc/test

I can access it with:

ssh r...@test.freedom.box

Maybe this is what you want?
My setup uses dnsmasq to do some DHCP/DNS magic. 
Wrote an article about my setup:

http://freedomboxblog.nl/installing-lxc-dhcp-and-dns-on-my-freedombox/

Rob.
http://freedomboxblog.nl



--
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of 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_122812
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] Networking between host and container

2012-12-28 Thread Marko Anastasov

On Dec 28, 2012, at 11:47 , Stéphane Graber stgra...@ubuntu.com wrote:

 On 12/28/2012 10:27 AM, Marko Anastasov wrote:
 Hello,
 
 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.
 
 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.
 
 Thanks,
 Marko
 
 Not exactly an answer to your question, but should be an answer to your
 problem anyway:
 http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/

Hi Stéphane,

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.

Eg output of host $(echo %h | sed s/\\.lxc//g) 10.0.3.1 is

Using domain server:
Name: 10.0.3.1
Address: 10.0.3.1#53
Aliases: 

Host %h not found: 3(NXDOMAIN)

Thanks,
Marko
--
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of 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_122812
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] Networking between host and container

2012-12-28 Thread Marko Anastasov

On Dec 28, 2012, at 13:07 , Rob van der Hoeven robvanderhoe...@ziggo.nl wrote:

 
 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.
 
 I'm using the default template in Ubuntu 12.04. 
 I have made a container template that I want to reuse.
 
 My setup uses the container name as its handle.
 If I create a container like this: 
 
 cd /var/lib/lxc
 mkdir test
 /usr/lib/lxc/templates/lxc-debian-box -n test -p /var/lib/lxc/test
 
 I can access it with:
 
 ssh r...@test.freedom.box
 
 Maybe this is what you want?
 My setup uses dnsmasq to do some DHCP/DNS magic. 
 Wrote an article about my setup:
 
 http://freedomboxblog.nl/installing-lxc-dhcp-and-dns-on-my-freedombox/
 

Hi Rob,

Yes that's exactly the setup I want. If nothing I'll try to extrapolate what 
you're doing on Debian with what's available on Ubuntu.

Thanks for sharing,
Marko
--
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of 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_122812
___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users


Re: [Lxc-users] Networking between host and container

2012-12-28 Thread Stéphane Graber
On 12/28/2012 01:20 PM, Marko Anastasov wrote:
 
 On Dec 28, 2012, at 11:47 , Stéphane Graber stgra...@ubuntu.com wrote:
 
 On 12/28/2012 10:27 AM, Marko Anastasov wrote:
 Hello,

 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.

 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.

 Thanks,
 Marko

 Not exactly an answer to your question, but should be an answer to your
 problem anyway:
 http://www.stgraber.org/2012/07/17/easily-ssh-to-your-containers-and-vms-on-ubuntu-12-04-lts/
 
 Hi Stéphane,
 
 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.

LXC in Ubuntu comes with dnsmasq-base and resolvconf was introduced by
default by me in Ubuntu 12.04, so you have it for sure or you're not
using a supported Ubuntu installation (resolvconf is part of
ubuntu-minimal).

 
 Eg output of host $(echo %h | sed s/\\.lxc//g) 10.0.3.1 is
 
 Using domain server:
 Name: 10.0.3.1
 Address: 10.0.3.1#53
 Aliases: 
 
 Host %h not found: 3(NXDOMAIN)

That's because once put in your ssh config, the %h will be replaced by
the name of your container.

Try host container name 10.0.3.1, that'll return the IP address of
your container as long as it's using DHCP for its IP configuration.

 Thanks,
 Marko
 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com



signature.asc
Description: OpenPGP digital signature
--
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of 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_122812___
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users