Quick and dirty LXC config with TUN adaptor and CPU throttle (debian)

lxc.net.0.type = veth

lxc.net.0.link = lxcbr0 (REPLACEME)

lxc.net.0.flags = up

lxc.net.0.hwaddr = 00:16:3e:00:01:02 (REPLACEME)

lxc.apparmor.profile = generated

lxc.apparmor.allow_nesting = 1

lxc.rootfs.path = dir:/REPLACE ME

 

# Common configuration

lxc.include = /usr/share/lxc/config/debian.common.conf

 

# Container specific configuration

lxc.tty.max = 4

lxc.uts.name = REPLACE ME

lxc.arch = amd64

lxc.pty.max = 1024

# CPU LIMITS

lxc.cgroup.cpu.cfs_quota_us = 7000

lxc.cgroup.cpu.cfs_period_us = 10000

#TUN

lxc.cgroup.devices.allow = c 10:200 rwm

lxc.hook.autodev = sh -c "modprobe tun; cd ${LXC_ROOTFS_MOUNT}/dev; mkdir net; mknod net/tun c 10 200; chmod 0666 net/tun"

lxc.start.auto = 1

This article was updated on April 19, 2024