The software described in this documentation is either in Extended Support or Sustaining Support. See https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdf for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.

27.2.6.1 Modifying a Container to Use a Static IP Address

By default, a container connected by macvlan relies on the DHCP server on your local network to obtain its IP address. If you want the container to act as a server, you would usually configure it with a static IP address. You can configure DHCP to serve a static IP address for a container or you can define the address in the container's config file.

To configure a static IP address that a container does not obtain using DHCP:

  1. Edit /container/name/rootfs/etc/sysconfig/network-scripts/ifcfg-iface, where iface is the name of the network interface, and change the following line:

    BOOTPROTO=dhcp

    to read:

    BOOTPROTO=none
  2. Add the following line to /container/name/config:

    lxc.network.ipv4 = xxx.xxx.xxx.xxx/prefix_length

    where xxx.xxx.xxx.xxx/prefix_length is the IP address of the container in CIDR format, for example: 192.168.56.100/24.

    Note

    The address must not already be in use on the network or potentially be assignable by a DHCP server to another system.

    To configure DNS, edit the hosts and resolv.conf files under /container/name/rootfs/etc.

    You might also need to configure the firewall on the host to allow access to a network service that is provided by a container.