Skip to content

Instantly share code, notes, and snippets.

@tarruda
Last active December 23, 2023 10:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarruda/ad71fc471c36fcdc82a20e82492198cb to your computer and use it in GitHub Desktop.
Save tarruda/ad71fc471c36fcdc82a20e82492198cb to your computer and use it in GitHub Desktop.
Libvirt lxc configurations
<domain type='lxc'>
<name>vpntest</name>
<uuid>ffee008c-ec6b-48ab-af6d-4aba830847a1</uuid>
<memory unit='GiB'>8</memory> <!-- The container can use at most 8G of memory -->
<idmap>
<uid start='0' target='300000' count='65536'/>
<gid start='0' target='300000' count='65536'/>
</idmap>
<os>
<type arch='x86_64'>exe</type>
<init>/sbin/init</init>
</os>
<devices>
<emulator>/usr/lib/libvirt/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/var/lib/libvirt/lxc/vpntest'/> <!-- this directory must have uids/gids starting from 300000 -->
<target dir='/'/>
</filesystem>
<filesystem type='mount' accessmode='passthrough'> <!-- passthrough /dev/net/tun from the host -->
<source dir='/dev/net'/>
<target dir='/dev/net'/>
</filesystem>
<hostdev mode='capabilities' type='misc'> <!-- give the necessary cgroup permission to access /dev/net/tun -->
<source>
<char>/dev/net/tun</char>
</source>
</hostdev>
<interface type='network'>
<mac address='52:54:00:3e:59:e9'/>
<source network='default'/>
</interface>
<console type='pty'>
<target type='lxc' port='0'/>
</console>
</devices>
</domain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment