  {"id":25965,"date":"2026-08-28T15:43:39","date_gmt":"2026-08-28T19:43:39","guid":{"rendered":"https:\/\/carleton.ca\/scs\/?p=25965"},"modified":"2026-08-28T15:43:39","modified_gmt":"2026-08-28T19:43:39","slug":"setup-port-forwarding-on-virtualbox-vm","status":"publish","type":"post","link":"https:\/\/carleton.ca\/scs\/2026\/setup-port-forwarding-on-virtualbox-vm\/","title":{"rendered":"Setup Port Forwarding on VirtualBox VM"},"content":{"rendered":"\n<section class=\"w-screen px-6 cu-section cu-section--white ml-offset-center md:px-8 lg:px-14\">\n    <div class=\"space-y-6 cu-max-w-child-5xl  md:space-y-10 cu-prose-first-last\">\n\n            <div class=\"cu-textmedia flex flex-col lg:flex-row mx-auto gap-6 md:gap-10 my-6 md:my-12 first:mt-0 max-w-5xl\">\n        <div class=\"justify-start cu-textmedia-content cu-prose-first-last\" style=\"flex: 0 0 100%;\">\n            <header class=\"font-light prose-xl cu-pageheader md:prose-2xl cu-component-updated cu-prose-first-last\">\n                                    <h1 class=\"cu-prose-first-last font-semibold !mt-2 mb-4 md:mb-6 relative after:absolute after:h-px after:bottom-0 after:bg-cu-red after:left-px text-3xl md:text-4xl lg:text-5xl lg:leading-[3.5rem] pb-5 after:w-10 text-cu-black-700 not-prose\">\n                        Setup Port Forwarding on VirtualBox VM\n                    <\/h1>\n                \n                                \n                                    \n\n<p class=\"wp-block-paragraph\">Port forwarding can be used with a VirtualBox Virtual Machine (VM) to quickly allow a network connection into the VM from the host.  For instance, if you need to ssh into a VM with a specific tool such as vscode, you can use port forwarding as a simple alternative to setting up a full host-only network.<\/p>\n\n\n                            <\/header>\n\n                    <\/div>\n\n            <\/div>\n\n    <\/div>\n<\/section>\n\n\n\n\n<div class=\"w-full max-w-xl mx-auto overflow-hidden bg-white rounded-lg shadow-lg cu-stackedlist cu-component not-contained not-prose\">\n    <h2 class=\"px-6 py-4 text-base font-semibold border-b rounded-t-lg md:text-xl bg-gray-50 text-cu-black-800\">\n        Table of Contents\n    <\/h2>\n    <div class=\"grid cu-scrollto cu-stackedlist--toc cu-stackedlist--1 md:grid-cols-1\">\n            <div class=\"space-y-1\">\n                    \n            <div class=\"pl-4 text-cu-red-700\">\n                <div class=\"flex gap-2 pb-3 text-base md:text-lg\">\n                    <span class=\"font-light text-cu-black-700\">\n                        1.\n                    <\/span>\n\n                    <a href=\"#steps-to-setup-port-forwarding\" class=\"font-medium hover:underline\">\n                        Steps to setup port forwarding\n                    <\/a>\n                <\/div>\n\n                            <\/div>\n                    \n            <div class=\"pl-4 text-cu-red-700\">\n                <div class=\"flex gap-2 pb-3 text-base md:text-lg\">\n                    <span class=\"font-light text-cu-black-700\">\n                        2.\n                    <\/span>\n\n                    <a href=\"#test-the-connection\" class=\"font-medium hover:underline\">\n                        Test the connection\n                    <\/a>\n                <\/div>\n\n                            <\/div>\n            <\/div>\n\n    <\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">This post assumes you already have a VM imported into VirtualBox<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong class=\"myprefix-text-bold\">NOTE<\/strong>: Some SCS VMs may have port-forwarding preconfigured<\/p>\n\n\n\n<h2 id=\"steps-to-setup-port-forwarding\" class=\"wp-block-heading\">Steps to setup port forwarding<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"774\" height=\"510\" src=\"https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-settings-vm.png\" alt=\"VirtualBox VM Network Settings Tab\" class=\"wp-image-25964\" style=\"width:774px;height:auto\" srcset=\"https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-settings-vm.png 774w, https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-settings-vm-512x337.png 512w, https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-settings-vm-320x211.png 320w, https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-settings-vm-768x506.png 768w\" sizes=\"auto, (max-width: 774px) 100vw, 774px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the settings for your VirtualBox VM and select the <em class=\"myprefix-text-italic\"><strong class=\"myprefix-text-bold\">Network<\/strong> <\/em>tab (see Red box above)<\/li>\n\n\n\n<li>Ensure that the Network adapter is <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Attached to: NAT<\/em><\/strong> (see Green box above)<\/li>\n\n\n\n<li>Click on the <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Port Forwarding<\/em><\/strong> button (see Purple box above)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"850\" height=\"175\" src=\"https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-portforwarding-vm-1.png\" alt=\"VirtualBox VM Network Port Forwarding Window\" class=\"wp-image-25966\" srcset=\"https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-portforwarding-vm-1.png 850w, https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-portforwarding-vm-1-512x105.png 512w, https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-portforwarding-vm-1-320x66.png 320w, https:\/\/carleton.ca\/scs\/wp-content\/uploads\/sites\/260\/2026\/08\/virtualbox-network-portforwarding-vm-1-768x158.png 768w\" sizes=\"auto, (max-width: 850px) 100vw, 850px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Port Forwarding Rules<\/em><\/strong> window, click the small <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">&#8220;plus&#8221; (+)<\/em><\/strong> icon to create a new rule (see Red box above)<\/li>\n\n\n\n<li>Fill in the desired port forwarding port numbers.  For instance, if you want to be able to ssh to localhost port 2222, to get to port 22 (ssh) on your virtual machine, you would enter port <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">2222 <\/em><\/strong>as the <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Host port<\/em><\/strong> (Green box) and port <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">22 <\/em><\/strong>as the <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Guest port<\/em><\/strong> (Purple box).<\/li>\n\n\n\n<li><strong class=\"myprefix-text-bold\">NOTE<\/strong>: You can rename <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Rule 1<\/em><\/strong> if you wish, but that is not required.  <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Host IP<\/em><\/strong> and <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">Guest IP<\/em><\/strong> should both be left blank<\/li>\n\n\n\n<li>Press the window&#8217;s <strong class=\"myprefix-text-bold\"><em class=\"myprefix-text-italic\">OK <\/em><\/strong>button to save<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The next time you start the VM, the port forwarding will be setup.  You may get a networking notification that a rule is being setup, and you may have to enter an admin password for your host device.<\/p>\n\n\n\n<h2 id=\"test-the-connection\" class=\"wp-block-heading\">Test the connection<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For the above example, you can test by using a terminal (mac\/linux terminal, vscode, powershell, etc) to try an ssh to the VM.  The username below is the username on your VM.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -p 2222 username@localhost<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This post assumes you already have a VM imported into VirtualBox NOTE: Some SCS VMs may have port-forwarding preconfigured Steps to setup port forwarding The next time you start the VM, the port forwarding will be setup. You may get a networking notification that a rule is being setup, and you may have to enter [&hellip;]<\/p>\n","protected":false},"author":626,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-25965","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":{"cu_post_thumbnail":""},"_links":{"self":[{"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/posts\/25965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/users\/626"}],"replies":[{"embeddable":true,"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/comments?post=25965"}],"version-history":[{"count":1,"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/posts\/25965\/revisions"}],"predecessor-version":[{"id":25967,"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/posts\/25965\/revisions\/25967"}],"wp:attachment":[{"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/media?parent=25965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/categories?post=25965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/carleton.ca\/scs\/wp-json\/wp\/v2\/tags?post=25965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}