[lxc-users] Networking in LXC
Fajar A. Nugraha
list at fajar.net
Tue Jun 10 12:04:55 UTC 2014
On Tue, Jun 10, 2014 at 6:39 PM, Ajith Adapa <ajith.adapa at gmail.com> wrote:
> Thanks for the reply @Fajar.
>
> (From Host)
> # lxc-attach -n root -- echo $PATH
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
>
> (Inside container)
> # ifconfig
> -bash: ifconfig: command not found
> # echo $PATH
> /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
That is odd. ifconfig should be on /sbin/ifconfig. And /sbin is in
your path inside the container. Not sure what's wrong.
>
> As you mentioned there is a difference in PATH. I am using default
> config to create a lxc container. Is it an issue with fedora or we
> have to manually set it everytime a container is created ?
My best suggestion would be to try lxc-1.0.3 from fedora rawhide. IIRC
fedora template on ubuntu (with lxc-1.0.3) works just fine.
>
> ================================================
>
> I have a doubt regarding binding a physical interface to a lxc-container.
>
> As per the instructions provided, we are creating a file at /run/netns
> say user1 and then attaching interfaces to the network namespace user1
> using ip command. Then we are using mount command to mount the network
> namespace user1 in the process.
No, what I wrote was:
- mount the container's net ns (so that you can modify it from the host)
- attach additional interfaces
- remove the netns (or unmount and delete, which would probably do the
same thing)
See how the order is different?
... and for the record, I'm not an lxc developer, so while the above
method might work, it's not necessarily the "correct" way to do so.
>
> If I restart the container then the container starts with the new
> process-id. Then if I try to mount the same network namespace user1 to
> new process I am not seeing the physical interfaces inside the
> container.
>
> Should I delete the network-namespace user1 when the container is
> stopped and create it again when we restart the container to make it
> work ?
err... don't use dynamically-attached interfaces?
if by "restart" you mean "shutdown and start again", then the way to
make it permanent is by editing the container's config file.
if by "restart" you mean "init 6 or reboot inside the container", then
yes, the newly-assigned net device will be back to the host, and no, I
don't know how to make it survive an "init 6".
--
Fajar
More information about the lxc-users
mailing list