zunkree

lxc config template

Sep 19th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. # set arch
  2.  
  3. lxc.arch =
  4.  
  5. # set the hostname
  6. lxc.utsname = <utsname>
  7.  
  8. # network interface
  9. lxc.network.type = veth
  10. lxc.network.flags = up
  11. # - name in host (max 15 chars; defaults to 'tun'+random)
  12. lxc.network.veth.pair = <veth_name>
  13. # - name in guest
  14. lxc.network.name = eth0
  15. # enable for bridging
  16. # (eg. 'brctl addbr br0; brctl setfd br0 0; brctl addif br0 eth0')
  17. lxc.network.link = lxcbr0
  18.  
  19. # root filesystem location
  20. lxc.rootfs = /var/lib/lxc/<utsname>/rootfs
  21.  
  22. # fstab
  23. lxc.mount = /var/lib/lxc/<utsname>/fstab
  24.  
  25. # console access
  26. lxc.tty = 1
  27. lxc.pts = 128
  28.  
  29. # this part is based on 'linux capabilities', see: man 7 capabilities
  30. # eg: you may also wish to drop 'cap_net_raw' (though it breaks ping)
  31. #
  32. # WARNING: the security vulnerability reported for 'cap_net_admin' at
  33. # http://mainisusuallyafunction.blogspot.com/2012/11/attacking-hardened-linux-systems-with.html
  34. # via JIT spraying (the BPF JIT module disabled on most systems was used
  35. # in the example, but others are suggested vulnerable) meant that users
  36. # with root in a container, that capability and kernel module may escape
  37. # the container. ALWAYS be extremely careful granting any process root
  38. # within a container, use a minimal configuration at all levels -
  39. # including the kernel - and multiple layers of security on any system
  40. # where security is a priority. note that not only LXC but PAX (and
  41. # others?) were vulnerable to this issue.
  42. #
  43. # conservative: lxc.cap.drop = sys_module mknod mac_override sys_boot
  44. # aggressive follows. (leaves open: chown dac_override fowner ipc_lock kill lease net_admin net_bind_service net_broadcast net_raw setgid setuid sys_chroot)
  45. lxc.cap.drop = audit_control audit_write dac_read_search ipc_owner linux_immutable mac_admin mac_override mknod setfcap sys_admin sys_boot sys_module sys_pacct sys_ptrace sys_rawio sys_resource sys_time sys_tty_config
  46.  
  47. # deny access to all devices by default, explicitly grant some permissions
  48. #
  49. # format is [c|b] [major|*]:[minor|*] [r][w][m]
  50. # ^ ^ ^
  51. # char/block -' `- device number `-- read, write, mknod
  52. #
  53. # first deny all...
  54. lxc.cgroup.devices.deny = a
  55. # /dev/null and zero
  56. lxc.cgroup.devices.allow = c 1:3 rw
  57. lxc.cgroup.devices.allow = c 1:5 rw
  58. # /dev/{,u}random
  59. lxc.cgroup.devices.allow = c 1:9 rw
  60. lxc.cgroup.devices.allow = c 1:8 r
  61. # /dev/pts/*
  62. lxc.cgroup.devices.allow = c 136:* rw
  63. lxc.cgroup.devices.allow = c 5:2 rw
  64. # /dev/tty{0,1}
  65. lxc.cgroup.devices.allow = c 4:1 rwm
  66. lxc.cgroup.devices.allow = c 4:0 rwm
  67. # /dev/tty
  68. lxc.cgroup.devices.allow = c 5:0 rwm
  69. # /dev/console
  70. lxc.cgroup.devices.allow = c 5:1 rwm
  71. # /dev/net/tun
  72. lxc.cgroup.devices.allow = c 10:200 rwm
Advertisement
Add Comment
Please, Sign In to add comment