Skip to Content
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Sign in
  • Nederlands English (US) Español (AR)
  • Contact Us
  • Home
  • Blog
  • Jobs
  • Contact us
Cafayate.Net
  • 0
  • 0
    • Home
    • Blog
    • Jobs
    • Contact us
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Sign in
  • Contact Us

LXC container gets two IP addresses assigned to it

  • All Blogs
  • Tech Blog
  • LXC container gets two IP addresses assigned to it
  • March 5, 2021 by
    Administrator

    So after a little bit more research I’ve determined why this is happening. I’m using the default Ubuntu and Debian templates to create the containers and their networking is set up so as to use DHCP to ask for a IP from the the router. So initially the static IP is set using the lxc.container.config and then when the container starts it queries the router (or whatever DHCP server you have) for a secondary IP that’s then assigned to it.

    The most logical way to stop this is likely to just assign the static ip inside the container. So on Debian based templates edit /etc/network/interfaces:

    auto etho0
    iface etho0 inet static
        address 192.168.0.15
        netmask 255.255.255.0
        gateway 192.168.0.1
    

    And then remove the ipv4 line from the lxc config /var/lib/lxc/testcontainer/config:

    lxc.network.type = veth
    lxc.network.link = br0
    

    Another method is to let the host set the ip by keeping the ipv4 line in /var/lib/lxc/testcontainer/config and to tell the container explicitly to not touch the interface by setting it to manual:

    auto eth0
    iface eth0 inet manual
    

    Apparently there are some issues with this second method if the host is suspended and then resumed. Probably best to use the first method.

    in Tech Blog
    How to attach LXC container to OVS (OpenvSwitch)

    Designed for companies

    We are a team of passionate people whose goal is to improve everyone's life through disruptive products. We build great products to solve your business problems. Our products are designed for small to medium size companies willing to optimize their performance.

    Get in touch

    Plantexel
    Pedernera
    Salta Capital 
    Argenina

    • +31 653-919-302
    • [email protected]
    Follow us
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)