{"id":3,"date":"2008-03-05T18:13:35","date_gmt":"2008-03-05T17:13:35","guid":{"rendered":"http:\/\/spinczyk.net\/blog\/?p=3"},"modified":"2008-08-03T14:06:55","modified_gmt":"2008-08-03T13:06:55","slug":"setting-up-a-bridged-network-for-virtualbox-on-ubuntu-linux","status":"publish","type":"post","link":"https:\/\/spinczyk.net\/blog\/2008\/03\/05\/setting-up-a-bridged-network-for-virtualbox-on-ubuntu-linux\/","title":{"rendered":"setting up a bridged network for virtualbox on ubuntu linux (Host Interface)"},"content":{"rendered":"<p>In order for this to run, you will most likely need a wired network connection, since most wireless-adapters won&#8217;t support bridged networking! This description is intended to be used with VirtualBox &gt;= 1.4.0, since earlier versions handle the virtual networking differently due to kernel changes in 2.6.18 and later.<\/p>\n<p>First of all, you&#8217;ll have to check the permissions on the device <span style=\"color: #993300;\">\/dev\/net\/tun <span style=\"color: #ffffff;\">. The user running VirtualBox with bridged networking needs to have access to this device. The easiest way to do this is by chown&#8217;ing the group vboxusers to it:<\/span> <\/span><\/p>\n<pre lang=\"bash\">sudo chown :vboxusers \/dev\/net\/tun\r\nsudo chmod 0660 \/dev\/net\/tun<\/pre>\n<p>You will also have to install the package bridge-utils and uml-utilities:<\/p>\n<pre lang=\"bash\">sudo apt-get install bridge-utils uml-utilities<\/pre>\n<p>Now we will create 2 scripts which are executed when the virtual machine starts\/stops. I will create those scripts in my home dir. Here is the start script, I called it starttun.sh:<\/p>\n<pre lang=\"bash\">#!\/bin\/bash\r\nbrctl addbr br0\r\nifconfig eth0 0.0.0.0\r\nbrctl addif br0 eth0\r\n\r\n#if you have a dhcp-server uncomment this line:\r\n#dhclient3 br0\r\n\r\n#If you have a static IP uncomment the following lines and<\/pre>\n<pre lang=\"bash\">#change the IP accordingly to your subnet:\r\n#ifconfig br0 192.168.178.5 up\r\n#route add default gw 192.168.178.1\r\n\r\n#Now we will create the tap device for the vm,!<\/pre>\n<pre lang=\"bash\"># change your username accordingly\r\ntunctl -t tap0 -u simon\r\n\r\n#Now add the tap-device to the bridge:\r\nifconfig tap0 up\r\nbrctl addif br0 tap0<\/pre>\n<p>Now you&#8217;ll have to create the stop script, i called it stoptun.sh \ud83d\ude09<\/p>\n<pre lang=\"bash\">#!\/bin\/bash\r\n#bring the interfaces down\r\nifconfig tap0 down\r\nifconfig br0 down\r\nbrctl delif br0 tap0\r\nbrctl delbr br0\r\n\r\n#now setup your network-interface again\r\n#for dhcp uncomment the following line\r\n#dhclient3 eth0\r\n\r\n#For a static IP uncomment the following lines and change them accordingly:\r\n#ifconfig eth0 192.168.178.5\r\n#route add default gw 192.168.178.1 dev eth0<\/pre>\n<p>Finally you&#8217;ll have to make the scripts executable:<\/p>\n<pre lang=\"bash\">sudo chmod ug+x starttun.sh\r\nsudo chmod ug+x stoptun.sh<\/pre>\n<p>It&#8217;s time to set up VirtualBox to use the interface. For this go to the SetUp of your Virtual Machine under Network and tell VirtualBox to start\/stop thescripts, when the VM is started\/stopped. To do this, select &#8220;Host Interface&#8221; under Attached To. As Interface Name you use &#8220;tap0&#8221; and for the startscript you use:<\/p>\n<p>&#8220;gksudo \/home\/YOURHOMEDIR\/starttun.sh&#8221;<\/p>\n<p>For the stopscript accordingly:<\/p>\n<p>&#8220;gksudo \/home\/YOURHOMEDIR\/stoptun.sh&#8221;<\/p>\n<p>Note: If you use KDE, you&#8217;ll have to use kdesu instead of gksudo<\/p>\n<div style=\"float:left;margin-right:10px;\"><iframe loading=\"lazy\" height=\"69\" width=\"53\" src=\"http:\/\/widgets.fbshare.me\/files\/fbshare.php?url=https:\/\/spinczyk.net\/blog\/2008\/03\/05\/setting-up-a-bridged-network-for-virtualbox-on-ubuntu-linux\/&title=setting up a bridged network for virtualbox on ubuntu linux (Host Interface)&size=large&google_analytics=true\" frameborder=\"0\" scrolling=\"no\" allowtransparency=\"true\"><\/iframe><\/div>","protected":false},"excerpt":{"rendered":"<p>In order for this to run, you will most likely need a wired network connection, since most wireless-adapters won&#8217;t support bridged networking! This description is intended to be used with VirtualBox &gt;= 1.4.0, since earlier versions handle the virtual networking differently due to kernel changes in 2.6.18 and later. First of all, you&#8217;ll have to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1,3],"tags":[35,36,12],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/posts\/3"}],"collection":[{"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/comments?post=3"}],"version-history":[{"count":1,"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/posts\/3\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/posts\/3\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/media?parent=3"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/categories?post=3"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spinczyk.net\/blog\/wp-json\/wp\/v2\/tags?post=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}