Session 3 : VirtualBox Networking (NAT & Port Forwarding, Bridged, Internal, Host-Only)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] hey guys welcome back as mentioned in the previous session today we will be discussing about networking in VirtualBox now I think this is an important topic because most of you would probably get stuck here if you don't do it right I know it's a little off course how are the things that are covered in this session is good to know information not just for her to grab but for any lab that you want to set up using VirtualBox let us start by first understanding my home network setup now at my home my internet connection is provided by an ISP which terminates on my home Wi-Fi router the Wi-Fi router then acts as my gateway which creates an internal LAN network for my home my Wi-Fi router is configured to use the IP range 192.168.1 t4 subnet for the internal LAN network all my connected devices including my PC get the IP configuration from the router via DHCP the Wi-Fi router which is also my gateway to the ISP band and a DHCP server for my internet home network has an internal IP of 192.168.1.1 similarly my PC has got an IP of 10.2 and so on note that this IP ranges for the internal home network and is not the same as the external IP provided by the ISP that terminates on the Wi-Fi router so this is a general and commonly found bond network setter and I'm sure most of you would be having somewhat similar setup at home now studying up network on virtual machines is quite different than setting it up on your PC or so having physical ports in case of virtual machines the networking layer is virtualized and hence in this session I will be giving a brief overview of how VirtualBox Network now for 90% of the cases the default virtual work settings are more than sufficient for normal VM operations however since our requirement includes setting up a cluster the default settings won't be sufficient in VirtualBox each vm that you create can have a total of eight virtual network adapters you can configure the first four network adapters from the application interface under settings and then network the other four interfaces can be added via the command line using v box managed on a sidenote Virtual Box provides a command line management tool called V box manage which is basically an exe file stored under the VirtualBox installation folder you can invoke the tool from the Windows command line however this is for advanced users and hence I won't be covering it in this video the graphical interface itself is more than sufficient for our requirement now under Advanced Options you can see the various virtual adapter types that you can choose from these are basically the hardware types supported and virtualized by VirtualBox choosing one usually depends upon the compatibility with your host OS and your requirements for all practical purposes you can just leave it with the default one also you can see VirtualBox selects the NAT mode by default now it is time for me to explain the different kinds of networking modes in a little more detail virtualbox supports various networking modes the list includes NAT or network address translation NAT network bridged adapter internal network and host-only adapter there is also generic driver which is rarely used and hence I'll be skipping that not on network address translation is the default selection for all VirtualBox network adapters now if you have any experience with networking before you should be knowing that network address translation is a well-known concept in networking wherein NAT mode VirtualBox Sheils the VM behind the host ID the VM connects to the external world by translating its IP to the host IP using it as a proxy now when you configure your VMs to use NAT VirtualBox basically creates a sort of internal network for each VM it will then map the source IPS of the VMS to the hosts IP using the VirtualBox NAT engine whenever the VM needs to contact the outside world now let me launch my VM using an ad adaptor to select NAT adapter go to network under the VM settings and select the networking mode as you can see NAT is selected by default let me launch the VM now my VM is launched so let me check the IP address that is assigned you can use a command if confident now this is the interface that is configured for the NAT and as you can see it is assigned an IP of 10.0 2.15 which is different from my home network that starts with 192.168.0 network created by virtual box for the VM the gateway IP is nothing but the virtual box not engine which somewhat acts like a virtualized router this means whenever the VM tries to connect to an outside Network resource the NAT engine on VirtualBox will translate the source IP address on the packets to the host IP which looks as if the host itself is connecting to it the VM now looks just like any other web application on the host machine for multiple VMs VirtualBox will create separate internal NAT networks in this mode the VM is shielded and cannot be accessed from the outside world from the host or even from other VMs however the VM can access the outside network using the host as proxy here you can see that the Internet is accessible from my VM however when I try to ping my VM IP from the host it is not accessible now VirtualBox does provide a way to access VMs behind NAT either from the host or from external network for this we must use something called as port forwarding again a well-known concept in networking now you can create port forwarding rules which tells the VirtualBox not engine running on the host that whenever the host adapter receives packet on a predefined port number it has to forward that packet to the VM by reverse translating its IP and port number to create a port forwarding rule for a VM go to network under the VM settings now with not selected go to advanced settings here you will see the option to set port forwarding rules now I am going to create a rule for allowing SSH connections to my VM to do this select add a new rule now in the host port put a user port number that you want to be forwarded to the VM I will enter a random port number two to eight one however make sure that no other service on the host is using the sport since it will create conflicts leave the host IP blank which means it will accept connection from all IDs second on the guest port put port number 22 which is for SSH and click OK let me launch my VM now now that the VM is up let me make sure that the SSH service is up on the VM and it is listening on port 22 you well this confirms sss service is up and running on the BM let's give it a try open your body terminal on your host select SSH and enter the port number as 2 2 8 1 enter the local host IP that is 120 Sun dot 0 dot 0 dot 1 since I am accessing the VM from the host itself if you are trying to access the VM from an outside network enter the host IP instead which in my case is 192.168.1.1 access the VM over SSH let me login to confirm that it is the same machine if config and there it is you can see that the IP assigned is 10.0 dot 2 dot 15 which is that of our VM now the host and other external resources can access the VM by sending packets to the host IP on the port number 2 2 8 1 that we configured the NAT engine will capture all the packets on this port number and will forward it to the VM on port 22 now remember pings still won't work since ICMP is a level 3 protocol and does not have a port number like SSH so that's all about NAT and port forwarding you can use port forwarding to set up web and other servers sitting behind that the second mode is the NAD netbook this is very similar to the previous one however here it allows you to create an internal nag network with other Williams in it all the VMS in the same NAT network will be able to talk with each other but the way they access the outside world will be the same that is using network address translation now to assign the NAT network to a VM you need to first create the network go to files preferences and then select network here you will see all the NAT networks created which in my case is none so I'll go ahead and create one there you go a new NAT network is created you can name it whatever you want and also configure its IP ranges and DHCP settings now go to the VM and select settings go to network and select NAT network in the networking modes here you will be able to choose the NAT network you want the VM to be part of you can see the network that we just created similarly you can create multiple NAT networks that your VMs can be part of now bridge Network takes a very different approach in case of bridge adapters VirtualBox uses the net filter driver on your host to directly intercept data packets from your physical network port this effectively creates a new virtualized network interface along with your host network interface this enables the VMS to directly communicate with the host and even take part in routing and bridging with the rest of your network to enable bridge networking select the VM and go to network under the VM settings here select bridge adapter in the networking mode and launch the VM now that our VM is up let me check the IP address assigned to it I have used the same if config command as you can see the VM has an IP 192.168.1.1 as my internal home network similarly my host has an IP 192.168.1.1 ected to my home network as if it were a separate interface from outside it will look as if two separate hosts have connected to the network every new VM I add in this mode will connect to the network as a new host I can also configure static IP on my VM however I have to make sure that it falls under the IP range of my home network configured on my Wi-Fi router and that no other device in the network uses the same IP I must also then manually configure DNS on the VM host details we'll see in the next session with bridged adapters you can access the VM over the network from other VMs in the network and from your host now bridged adapters are suitable for our Hadoop lab setup as it will allow us to create multiple VMs with static IPS that can talk to each other can connect to the internet and can be accessed from the host however be careful while connecting your hosts to office or other networks while the VMS are on in this mode you should be aware that the VMS will have direct access to the network and any unwanted services running on them can lead to Network disruptions also bridge adapters won't be suitable for our lab if you are using direct wired internet connection from ISP or dongles this is because you will have limited or no control over the IPS assigned to you from ISP you can only use DHCP IP assignment in such cases which won't work out if you want to setup a Hadoop cluster with static IP s-- this mode can be used to create internal virtual box networks where VMs can talk to each other internally by default all VMs in this mode will be part of the internal network INAT however you can specify a new name to create a new network in this mode the VMS cannot access or be accessed from the outside Network or even from the host now the host-only wood allows you to create an internal network with the host being part of it now this is very similar to the previous mode that we discussed however in this case in addition to creating an internal network it also allows connection to the host in this mode VirtualBox specifically creates a new network adapter for the host using which the host can connect to the internal VirtualBox host only network again as with other modes you can create multiple host only networks as you can see under file preferences Network there is a section for host only networks by default we have one host only network created now if I right-click and go to edit here you can configure the adapter IP and a network IP ranges in DHCP currently it is configured to use a Class C IP range 192.168.0 and we will leave it to that you can also create more such networks if you want now on a Windows 7 host machine if I go to network and sharing center and select change adapter settings here you can see the host-only adapter created by VirtualBox on my host for the network which I just showed you remember if you create a new host only network on VirtualBox a new network adapter will be created here if you right-click go to properties and checked its ipv4 settings you will see it has the same IP which we saw and VirtualBox host only network adapter properties now your host will use this virtual adapter to talk with your VMs in your host only network LAN in host only network mode the VMs can talk to each other and with the host however the VMS cannot connect to any outside network or the Internet let me quickly show you how to configure the host only mode on my VM go to VM settings and select Network now change the mode to host only here you can serve the host only network that you want the VM to be part of let's boot up the machine now by default my VM is configured for DHCP and will get an automatic IP from the DHCP server built into VirtualBox now let us check the IP using if conflict as you can see the IP assigned is 192.168.10.0 as you can see here internet is not accessible on my VM in this mode however on my host machine if I open the command prompt and ping the VM IP you can see that it is reachable now the concepts that we learned today can be easily applied to other hypervisors as well like the VMware Workstation with slight changes here and there you can refer this link if you want to read more on this topic which aren't included in the description below now that we have seen the basics of VirtualBox networking we will next see how to configure static IPS and other Network configurations on ascend Western system so stay tuned and don't forget to Like share and subscribe see you next time [Music]
Info
Channel: TheITNoob
Views: 174,779
Rating: undefined out of 5
Keywords: virtualbox networking, NAT, network address translation, port forwarding, Bridged Adapter, Internal Network, Host Only Network, Tutorial, Session, Virtualbox, Network
Id: cDF4X7RmV4Q
Channel Id: undefined
Length: 18min 29sec (1109 seconds)
Published: Fri Nov 17 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.