ta-ching chen

1 minute read

 Table of Contents

Prerequisites 

  • Ubuntu 14.04 LTS (Trusty Tahr)

LXC(LinuX Container) has only one network interface when its created, so we have to add other interfaces manually.

Create an container 

sudo lxc-create -t download -n <cotnainer name> -- -d ubuntu -r trusty -a amd64

And now, LXC creates a pair of tap devies. One connects to container, another one connects to OVS bridge.

Container Network

Modify Config 

You will see somthing like this in /var/lib/lxc/<container name>/config

# Network configuration
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:aa:cc:9c

Just copy/paste original network configuration in file and change

  • lxc.network.hwaddr (MAC address)

Optional:

  • lxc.network.link (the bridge name that virtual interface connects to)

Example 

  • /var/lib/lxc/<container name>/config
# Network configuration
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:aa:cc:9c

lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.hwaddr = 00:16:3e:aa:cc:9D

Reference 

See Also

To reproduce, republish or re-use the content, please attach with link: https://tachingchen.com/
comments powered by Disqus