{"id":75,"date":"2013-05-18T20:35:10","date_gmt":"2013-05-18T20:35:10","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=75"},"modified":"2013-05-18T20:35:10","modified_gmt":"2013-05-18T20:35:10","slug":"how-to-enable-tuntap-module-in-openvz","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2013\/05\/18\/how-to-enable-tuntap-module-in-openvz\/","title":{"rendered":"How to Enable TUN\/TAP Module in OpenVZ"},"content":{"rendered":"<div>OpenVZ supports VPN inside a container via kernel TUN\/TAP module and device. To allow VPS #101 to use the TUN\/TAP device the following should be done:<\/div>\n<div><\/div>\n<div>#101 &#8211; VPS\u00a0 id. Replace #101 with your VPS id.<\/div>\n<div><\/div>\n<div>Make sure the tun module has already loaded on the Node.<\/div>\n<div>[root@Node \/]#\u00a0<b>\u00a0lsmod | grep tun<\/b><\/div>\n<div><\/div>\n<div>If not listed, then load the tun module with the below command<\/div>\n<div>[root@Node<b>\u00a0<\/b>\/]#<b>\u00a0modprobe tun<\/b><b>\u00a0<\/b>[root@Node \/]#\u00a0<b>\u00a0lsmod | grep tun<\/b><br \/>\n<b>\u00a0 tun\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 82432\u00a0 6<\/b><\/p>\n<\/div>\n<div><\/div>\n<div><b>Run the following command in Node:<\/b><\/div>\n<div><\/div>\n<pre>[root@Node \/]# <b> vzctl set 101 --devnodes net\/tun:rw --save<\/b><\/pre>\n<pre>[root@Node \/]#  <b>vzctl set 101 --devices c:10:200:rw --save<\/b><b>\u00a0<\/b><\/pre>\n<pre>[root@Node \/]# <b> vzctl stop 101<\/b><b> <\/b><\/pre>\n<pre>[root@Node \/]# <b> vzctl set 101 --capability net_admin:on --save<\/b><\/pre>\n<pre>[root@Node \/]#  <b>vzctl start 101 <\/b><\/pre>\n<pre>[root@Node \/]# <b> vzctl exec 101 mkdir -p \/dev\/net<\/b><\/pre>\n<pre>[root@Node \/]#  <b>vzctl exec 101 chmod 600 \/dev\/net\/tun <\/b><\/pre>\n<pre><\/pre>\n<pre><b>To check TUN\/TAP is enabled or not :<\/b><\/pre>\n<pre>[root@Node<b> <\/b>\/]#<b> vzctl enter 101<\/b><\/pre>\n<pre><b>\u00a0<\/b><\/pre>\n<pre><b>Inside the VPS: <\/b><\/pre>\n<pre>[root@vps \/]# <b>cat \/dev\/net\/tun<\/b><\/pre>\n<pre><b>cat: \/dev\/net\/tun: File descriptor in bad state     \n\n#<\/b> It means the TUN\/TAP is enabled on your VPS.<\/pre>\n<pre><b>\u00a0<\/b><\/pre>\n<pre> <b>cat: \/dev\/net\/tun: No such device<\/b><b>\u00a0    \n\n# <\/b><b> <\/b>If you receive like this, then the TUN\/TAP has not enabled on your VPS . Try to enable TUN\/TAP again and check.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>OpenVZ supports VPN inside a container via kernel TUN\/TAP module and device. To allow VPS #101 to use the TUN\/TAP device the following should be done: #101 &#8211; VPS\u00a0 id. Replace #101 with your VPS id. Make sure the tun module has already loaded on the Node. [root@Node \/]#\u00a0\u00a0lsmod | grep tun If not listed, [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[60],"tags":[61,62],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry","category-linux","tag-openvz","tag-tuntap-openvz"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}