[lxc-users] lxd: getting rid of the initial network interface

Stéphane Graber stgraber at ubuntu.com
Sun Feb 12 17:45:33 UTC 2017


On Sun, Feb 12, 2017 at 10:01:17AM +0100, Frans Meulenbroeks wrote:
> Hi,
> 
> I want to get rid of the network interface that my container has, but
> somehow I can't figure out how to get that done.
> 
> I have created a new container from scratch with:
> lxc launch ubuntu:14.04 my-ubuntu
> 
> lxc config show my-ubuntu gives;
> 
> architecture: x86_64
> config:
>   image.architecture: amd64
>   image.description: ubuntu 14.04 LTS amd64 (release) (20170202.1)
>   image.label: release
>   image.os: ubuntu
>   image.release: trusty
>   image.serial: "20170202.1"
>   image.version: "14.04"
>   volatile.base_image:
> 3b825a6a063aacc6b19df84f7ddc4fe872a0e382ec0bb92f475a9493b0857e01
>   volatile.eth0.hwaddr: 00:16:3e:25:48:06
>   volatile.idmap.base: "0"
>   volatile.idmap.next:
> '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":231072,"Nsid":0,"Maprange":65536}]'
>   volatile.last_state.idmap:
> '[{"Isuid":true,"Isgid":false,"Hostid":231072,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":231072,"Nsid":0,"Maprange":65536}]'
>   volatile.last_state.power: RUNNING
> devices:
>   root:
>     path: /
>     type: disk
> ephemeral: false
> profiles:
> - default

That shows that your container is inheriting from the "default" profile
which likely does include that eth0 device.

    lxc config show --expanded my-ubuntu

Would show you the config with the profiles applied.

To remove something that's inherited from a profile, you have to mask it
with something like:

    lxc config device add my-ubuntu eth0 none

Which masks the inherited device "eth0" with an empty one.

> Note: no nic device, but there is a volatile.eth0.hwaddr address
> 
> And if I look into the container with lxc exec my-ubuntu --  ifconfig -a
> 
> eth0      Link encap:Ethernet  HWaddr 00:16:3e:25:48:06
>           inet addr:10.202.122.138  Bcast:10.202.122.255  Mask:255.255.255.0
>           inet6 addr: fe80::216:3eff:fe25:4806/64 Scope:Link
>           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
>           RX packets:95 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:74 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1000
>           RX bytes:19120 (19.1 KB)  TX bytes:7960 (7.9 KB)
> 
> lo        Link encap:Local Loopback
>           inet addr:127.0.0.1  Mask:255.0.0.0
>           inet6 addr: ::1/128 Scope:Host
>           UP LOOPBACK RUNNING  MTU:65536  Metric:1
>           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>           collisions:0 txqueuelen:1
>           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
> 
> And if I do lxc network show lxdbr0 I see that the container is using the
> bridge.
> 
> $ lxc network show lxdbr0
> config:
>   dns.mode: dynamic
>   ipv4.address: 10.202.122.1/24
>   ipv4.dhcp.ranges: 10.202.122.2-10.202.122.254
>   ipv4.nat: "true"
>   ipv6.address: none
> name: lxdbr0
> type: bridge
> usedby:
> ...
> - /1.0/containers/my-ubuntu
> ...
> managed: true
> 
> 
> ButI cannot remove the device from the bridge:
> 
> lxc network detach lxdbr0 my-ubuntu
> error: No device found for this network
> 
> Is there a way to get rid of this interface?
> 
> (actually I want to attach eth0 to a different bridge)

To attach it to a different bridge, you'll want to mask the inherited
"eth0" with another eth0 that's attached to the bridge you want:


    lxc config device add my-ubuntu eth0 nic nictype=bridged parent=new-bridge


Or on recent LXD, this will achieve the same:

    lxc network attach new-bridge my-ubuntu eth0

> 
> Thanks in advance!
> Frans

> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20170212/0aba7ea7/attachment.sig>


More information about the lxc-users mailing list