{"id":249,"date":"2009-05-18T15:43:08","date_gmt":"2009-05-18T18:43:08","guid":{"rendered":"http:\/\/wordpress.matbra.com\/?p=249"},"modified":"2010-07-25T02:08:31","modified_gmt":"2010-07-25T05:08:31","slug":"redirecionando-portas-para-virtualbox","status":"publish","type":"post","link":"https:\/\/wordpress.matbra.com\/en\/2009\/05\/18\/redirecionando-portas-para-virtualbox\/","title":{"rendered":"Forwarding ports to a VirtualBox"},"content":{"rendered":"<p>Good afternoon,<\/p>\n<p>If you want to forward ports to a virtualmachine in VirtualBox you should do this:<\/p>\n<p>Create an interface &#8220;tap&#8221;<\/p>\n<blockquote><p>#sudo tunctl  -u $USER<\/p><\/blockquote>\n<p>Set the tap address:<\/p>\n<blockquote><p>#sudo ip addr add 192.168.0.20\/32 dev tap0<br \/>\n# sudo ip link set tap0 up<\/p><\/blockquote>\n<p>Enable Ip Forward<\/p>\n<blockquote><p># sudo sysctl net.ipv4.ip_forward=1<\/p><\/blockquote>\n<p>Add route:<\/p>\n<blockquote><p>#sudo route add -host 192.168.0.150 dev tap0<\/p><\/blockquote>\n<p>Create nat:<\/p>\n<blockquote><p># sudo iptables &#8211;flush<br \/>\n#sudo iptables -t nat &#8211;flush<br \/>\n#sudo iptables -t nat -A POSTROUTING &#8211;out-interface eth1 -j MASQUERADE<br \/>\n#sudo iptables -A FORWARD &#8211;in-interface eth1 -j ACCEPT<\/p><\/blockquote>\n<p>Redirecting port 3333 to 3389:<\/p>\n<blockquote><p>#iptables -t nat -A  PREROUTING -i eth1 -p tcp -d 192.168.0.100 &#8211;dport 3333  -j DNAT &#8211;to  192.168.0.150:3389<\/p><\/blockquote>\n<p>eth1 &#8211; Ethernet connected to the router.<br \/>\n192.168.0.150 &#8211; IP of virtualmachine<br \/>\n192.168.0.20 &#8211; IP of tap<br \/>\n192.168.0.100 &#8211; IP of my real machine that receive the connections in 3333<\/p>\n<p>After this configure manually your virtualmachine to: <\/p>\n<p>IP: 192.168.0.150<br \/>\nSubnet Mask: 255.255.255.0<br \/>\nDefault Gateway: 192.168.0.100<\/p>\n<p>I had problems with &#8216;&#8211;&#8216; so here is a file with the commands: <a href=\"http:\/\/wordpress.matbra.com\/?attachment_id=261\">Forward ports to a virtualmachine.<\/a><\/p>\n<p>Hope this is usefull,<br \/>\nMatheus<\/p>\n<p>References:<br \/>\n<a href=\"http:\/\/iptables-tutorial.frozentux.net\/iptables-tutorial.html\" target=\"_blank\">IPtables Tutorial<\/a><br \/>\n<a href=\"http:\/\/forum.slicehost.com\/comments.php?DiscussionID=2497\" target=\"_blank\">IPTables Port Redirect<\/a><br \/>\n<a href=\"http:\/\/www.savvyadmin.com\/virtualbox-host-interface-networking-with-nat\/\" target=\"_blank\">VirtualBox, com nat<\/a><br \/>\n<a href=\"http:\/\/mediakey.dk\/~cc\/opening-and-forwarding-ports-to-virtualbox-based-server\/\" target=\"_blank\">VBoxManage Port Forward<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Good afternoon, If you want to forward ports to a virtualmachine in VirtualBox you should do this: Create an interface &#8220;tap&#8221; #sudo tunctl -u $USER&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/wordpress.matbra.com\/en\/2009\/05\/18\/redirecionando-portas-para-virtualbox\/\">Continue reading<span class=\"screen-reader-text\">Forwarding ports to a VirtualBox<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[34],"tags":[40,97,96,35],"class_list":["post-249","post","type-post","status-publish","format-standard","hentry","category-linux","tag-maquina-virtual","tag-porta","tag-redirecionamento","tag-virtualbox","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/psjGE-41","_links":{"self":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}