FedoraForum.org - Fedora Support Forums and Community
Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2013
    Location
    HU
    Posts
    85

    LXC container static IP + dhcp IP?

    Hi!
    I use F27 server with LXC (2.0.9). (bridged host network interface: br0)
    I have a fedora container and it has 2 IP addresses: 1 static + 1 dhcp
    Code:
    # container config:
    lxc.include = /usr/share/lxc/config/fedora.common.conf
    lxc.arch = x86_64
    
    # Container specific configuration
    lxc.rootfs = /var/lib/lxc/fedora-lxc1/rootfs
    lxc.rootfs.backend = dir
    lxc.utsname = fedora-lxc1
    
    # Network configuration
    lxc.network.type = veth
    lxc.network.link = br0
    lxc.network.flags = up
    lxc.network.hwaddr = xx:xx:xx:xx:xx:xx
    # IP
    lxc.network.ipv4 = 10.0.0.105/8
    lxc.network.ipv4.gateway = 10.0.0.254
    It gets a dhcp IP address. Why?
    Code:
    container ~# ip addr
    ...
    14: eth0@if15: mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:2e:2c:d2:a2 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.105/8 brd 10.255.255.255 scope global eth0
    valid_lft forever preferred_lft forever
    inet 192.168.0.11/24 brd 192.168.0.255 scope global dynamic eth0
    valid_lft 25972sec preferred_lft 25972sec
    inet6 fe80::216:3eff:fe7c:d0a3/64 scope link
    valid_lft forever preferred_lft forever

  2. #2
    Join Date
    Oct 2011
    Posts
    1,798

    Re: LXC container static IP + dhcp IP?

    How did you setup host machine network. You need to configure a bridge "br0" first on the host and then connect network card through that. See: https://wiki.debian.org/LXC/SimpleBridge
    https://access.redhat.com/documentat...Network_Bridge
    Last edited by srakitnican; 11th April 2018 at 05:19 PM.

  3. #3
    Join Date
    Sep 2013
    Location
    HU
    Posts
    85

    Re: LXC container static IP + dhcp IP?

    I setup the br0 later (in NetworkManager). After first boot enp0s3 is existed.
    enp0s3 -> br0

  4. #4
    Join Date
    Oct 2011
    Posts
    1,798

    Re: LXC container static IP + dhcp IP?

    Inside the container remove the file `/etc/sysconfig/network-scripts/ifcfg-eth0` or similar. If you look at the file you should see a DHCP configuration. Not sure what initially created it.

  5. #5
    Join Date
    Sep 2013
    Location
    HU
    Posts
    85

    Re: LXC container static IP + dhcp IP?

    The LXC container does not contain file "ifcfg-eth0". Only "ifcfg-lo"!

  6. #6
    Join Date
    Oct 2011
    Posts
    1,798

    Re: LXC container static IP + dhcp IP?

    NetworkManager has it's own configuration, maybe look there.

  7. #7
    Join Date
    Sep 2013
    Location
    HU
    Posts
    85

    Re: LXC container static IP + dhcp IP?

    Quote Originally Posted by srakitnican
    NetworkManager has it's own configuration, maybe look there.
    NM is not running in container.

Similar Threads

  1. Static ip in FC7 - not dhcp
    By bananasfk in forum Servers & Networking
    Replies: 3
    Last Post: 18th June 2007, 08:27 PM
  2. Specifying a static IP with DHCP
    By sfboarders in forum Servers & Networking
    Replies: 5
    Last Post: 24th May 2005, 08:26 PM
  3. FC2 Overriding static if in favor of dhcp system set for static
    By pkraus109 in forum Servers & Networking
    Replies: 2
    Last Post: 21st September 2004, 05:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •