SlideShare a Scribd company logo
1 of 9
Download to read offline
Networking Between Host and Guest VMs
                       (Host-only Networking with VirtualBox)




- Ideal network configurations for VirtualBox
- Network Address Translate
- Host-only Networking


                                                                Alex Hahn
                                                                   2012.02
Scenario
◈ Objectives
  To develop and test in distributed environment you might use virtualizing tool like VirtualBox
  to imitate the environment of where number of servers and complex networks resides. But
  still, you have to move around through VM windows. In order to access all virtual servers
  using SSH just like we do in the real world, several things should be done first.
  - Setup Host-only Networking
  - Configure guest OS
◈ Requirements
  To achieve the goal, a virtualization tool (VirtualBox will be used here) and a little bit of
  networking knowledge is necessary which will be handled below.
  Of course you need your own laptop and Linux server OS for guest VMs.


   Ubuntu 11.10                                VirtualBox 4.1.8 for Linux
   Desktop 32bit
   - CPU 2 Core             Window XP             Ubuntu 11.10 Server       Ubuntu 11.10 Server
   - RAM 4 GB            1vCore / 1GB / 20GB       1vCore / 512MB / 3GB     1vCore / 512MB / 3GB
   - HDD 256 GB

                                   [An example of virtual environment]
Virtual Machine Network Structure
◈ Network configuration
   Separate network is necessary for host OS to access guest VMs
   To do that, each guest VMs should have two network adapters
   One is for guest VM to access outbound network, namely NAT adapter
   Another is for host OS to access each guest VM, namely Host-only adapter

                                  Host OS
                               IP : 192.168.0.11

                                 VirtualBox                                  Virtual Domain Static IP Settings
                                                                                            - 10.0.2.15 (IP)
                                        Host-only IP : 10.0.2.1                             - 10.0.2.2 (Gateway)
                                                                                            - 10.0.2.3(DNS)




    eth0   eth1         eth0    eth1           eth0      eth1         eth0   eth1


     Guest VM #1         Guest VM #2               Guest VM #3         Guest VM #4
     eth0 : 10.0.2.15    eth0 : 10.0.2.15          eth0 : 10.0.2.15    eth0 : 10.0.2.15           Virtual NIC
     eth1 : 10.1.2.11    eth1 : 10.1.2.12          eth1 : 10.1.2.13    eth1 : 10.1.2.14
                                                                                             NAT Network

                                                                                             Host-only Network
Networking
◈ NAT (Network Address Translation)
   NAT feature is included in most of our home routers.
   It creates a single separate sub network below the inbound IP (public IP) so that
    number of machines can get an internet access and can share with each other too.
   But in VirtualBox, NAT is attached to each VM which is so called ‘Basic NAT’ that does
    one-to-one translation, and in contrast home routers do one-to-many translation.
   That’s why with default adapters for VMs, they can’t see each other, even from the host.
   Actually, IP, Gateway, DNS is somewhat ‘hard coded’ in VirtualBox’s NAT Adapter.

                        ISP                                               Host OS


               Home Router NAT
                                                                   VirtualBox NAT
                  G/W : 192.168.0.1


                                                           Basic NAT                  Basic NAT

    IP : 192.168.0.2          IP : 192.168.0.3           IP : 10.0.2.15             IP : 10.0.2.15
    G/W : 192.168.0.1         G/W : 192.168.0.1          G/W : 10.0.2.2             G/W : 10.0.2.2
    DNS : x.x.x.x             DNS : x.x.x.x              DNS : 10.0.2.3             DNS : 10.0.2.3

  □ All machines are allocated to one sub network.   □ Each VM has its own sub network.
Networking
◈ Host-only Networking
   NAT is useful for guest VMs to access outbound network but as it is treated as a
    separate network, there is no way for host OS to access each guest OS.
   Bridged networking is used to handle this problem in real world, but it implies complexity.
   Host-only networking is kind of hybrid between internal and bridged networking.
   In VirtualBox (Host), Host-only network is a gateway for host (external network) to
    access guest VMs (internal network) to communicate with each other. So, it doesn’t
    need to be created as many the number of guest VMs.


                                             192.168.0.1



                                     Host-only Network
                                                                       Gateway
                                              10.1.2.1




                                 10.1.2.11                 10.1.2.12
Considerations
◈ Each NAT adapters and Host-only adapter should not reside in same sub-network
    eth0 -10.0.2.15 and eth1-10.0.2.12 wouldn’t work
    eth0 -10.0.2.15 and eth1-10.1.2.11 is good
    Where eth0 is for NAT and eth1 is for Host-only

◈ Each VM should have different host name.
    VM1 : ubuntu1, VM2 : ubuntu2
    “$ sudo hostname ubuntu2” on new VM and reboot

◈ Make sure to set different MAC address for new VM
    Rather installing a fresh new VM, use clone feature in VirtualBox
    First, take a snapshot of well setup VM and make a clone
    At clone, check ‘Reinitialize the MAC address of all network cards’ option

◈ After booting second VM, reset ‘udev’ network rules to set new IPs properly
    Remove /etc/udev/rules.d/70-persistent-net.rules (recreated at new boot)
    Check ‘ifconfig’ for eth0 and eth1

◈ Use static IP rather than DHCP on Host-only Network and set host alias.
    IP of Host-only adapter will change when guest VM reboots, so turn off DHCP in VirtualBox
    When guest IPs are fixed define an alias for each guest and configure hosts file in host OS
Instructions
◈ Step by Step configuration
   Step 1 : Setup default networking for guest VM with NAT
   Step 2 : Create Host-only Networking in VirtualBox
   Step 3 : Setup secondary adapter for each guest VM
   Step 4 : Configure guest VM
   Step 5 : Easier access to guest VMs with ‘hosts’ configuration
Testing
◈ Host Machine
   Ping to all guest Host-only IPs (10.1.2.11, 10.1.2.12 …)
   SSH to all guest VM


◈ Guest Machine
   Ping to ‘www.google.com’ to make sure external network works well including DNS.
   Ping to gateway (10.1.2.1)
   Ping to other guest VM.
   Check SSH daemon running. (ps –ef | grep sshd)
   Check firewall open (default is all open in ubuntu server)
References
◈ Reference Sites
  http://christophermaier.name/blog/2010/09/01/host-only-networking-with-virtualbox
  http://allisterx.blogspot.com/2008/05/additions-and-ssh-access-to-virtualbox.html
  http://serverfault.com/questions/308229/virtual-box-host-only-adapter-configuration
  http://jackal777.wordpress.com/2012/02/13/internet-access-in-virtualbox-host-only-networking/
  http://www.ubuntugeek.com/how-to-set-up-host-interface-networking-for-virtualbox-on-ubuntu.html
  http://superuser.com/questions/144453/virtualbox-guest-os-accessing-local-server-on-host-os
  http://www.virtualbox.org/manual/ch09.html#changenat

More Related Content

Recently uploaded

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Recently uploaded (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Networking between host and guest VMs in VirtualBox

  • 1. Networking Between Host and Guest VMs (Host-only Networking with VirtualBox) - Ideal network configurations for VirtualBox - Network Address Translate - Host-only Networking Alex Hahn 2012.02
  • 2. Scenario ◈ Objectives To develop and test in distributed environment you might use virtualizing tool like VirtualBox to imitate the environment of where number of servers and complex networks resides. But still, you have to move around through VM windows. In order to access all virtual servers using SSH just like we do in the real world, several things should be done first. - Setup Host-only Networking - Configure guest OS ◈ Requirements To achieve the goal, a virtualization tool (VirtualBox will be used here) and a little bit of networking knowledge is necessary which will be handled below. Of course you need your own laptop and Linux server OS for guest VMs. Ubuntu 11.10 VirtualBox 4.1.8 for Linux Desktop 32bit - CPU 2 Core Window XP Ubuntu 11.10 Server Ubuntu 11.10 Server - RAM 4 GB 1vCore / 1GB / 20GB 1vCore / 512MB / 3GB 1vCore / 512MB / 3GB - HDD 256 GB [An example of virtual environment]
  • 3. Virtual Machine Network Structure ◈ Network configuration  Separate network is necessary for host OS to access guest VMs  To do that, each guest VMs should have two network adapters  One is for guest VM to access outbound network, namely NAT adapter  Another is for host OS to access each guest VM, namely Host-only adapter Host OS IP : 192.168.0.11 VirtualBox Virtual Domain Static IP Settings - 10.0.2.15 (IP) Host-only IP : 10.0.2.1 - 10.0.2.2 (Gateway) - 10.0.2.3(DNS) eth0 eth1 eth0 eth1 eth0 eth1 eth0 eth1 Guest VM #1 Guest VM #2 Guest VM #3 Guest VM #4 eth0 : 10.0.2.15 eth0 : 10.0.2.15 eth0 : 10.0.2.15 eth0 : 10.0.2.15 Virtual NIC eth1 : 10.1.2.11 eth1 : 10.1.2.12 eth1 : 10.1.2.13 eth1 : 10.1.2.14 NAT Network Host-only Network
  • 4. Networking ◈ NAT (Network Address Translation)  NAT feature is included in most of our home routers.  It creates a single separate sub network below the inbound IP (public IP) so that number of machines can get an internet access and can share with each other too.  But in VirtualBox, NAT is attached to each VM which is so called ‘Basic NAT’ that does one-to-one translation, and in contrast home routers do one-to-many translation.  That’s why with default adapters for VMs, they can’t see each other, even from the host.  Actually, IP, Gateway, DNS is somewhat ‘hard coded’ in VirtualBox’s NAT Adapter. ISP Host OS Home Router NAT VirtualBox NAT G/W : 192.168.0.1 Basic NAT Basic NAT IP : 192.168.0.2 IP : 192.168.0.3 IP : 10.0.2.15 IP : 10.0.2.15 G/W : 192.168.0.1 G/W : 192.168.0.1 G/W : 10.0.2.2 G/W : 10.0.2.2 DNS : x.x.x.x DNS : x.x.x.x DNS : 10.0.2.3 DNS : 10.0.2.3 □ All machines are allocated to one sub network. □ Each VM has its own sub network.
  • 5. Networking ◈ Host-only Networking  NAT is useful for guest VMs to access outbound network but as it is treated as a separate network, there is no way for host OS to access each guest OS.  Bridged networking is used to handle this problem in real world, but it implies complexity.  Host-only networking is kind of hybrid between internal and bridged networking.  In VirtualBox (Host), Host-only network is a gateway for host (external network) to access guest VMs (internal network) to communicate with each other. So, it doesn’t need to be created as many the number of guest VMs. 192.168.0.1 Host-only Network Gateway 10.1.2.1 10.1.2.11 10.1.2.12
  • 6. Considerations ◈ Each NAT adapters and Host-only adapter should not reside in same sub-network  eth0 -10.0.2.15 and eth1-10.0.2.12 wouldn’t work  eth0 -10.0.2.15 and eth1-10.1.2.11 is good  Where eth0 is for NAT and eth1 is for Host-only ◈ Each VM should have different host name.  VM1 : ubuntu1, VM2 : ubuntu2  “$ sudo hostname ubuntu2” on new VM and reboot ◈ Make sure to set different MAC address for new VM  Rather installing a fresh new VM, use clone feature in VirtualBox  First, take a snapshot of well setup VM and make a clone  At clone, check ‘Reinitialize the MAC address of all network cards’ option ◈ After booting second VM, reset ‘udev’ network rules to set new IPs properly  Remove /etc/udev/rules.d/70-persistent-net.rules (recreated at new boot)  Check ‘ifconfig’ for eth0 and eth1 ◈ Use static IP rather than DHCP on Host-only Network and set host alias.  IP of Host-only adapter will change when guest VM reboots, so turn off DHCP in VirtualBox  When guest IPs are fixed define an alias for each guest and configure hosts file in host OS
  • 7. Instructions ◈ Step by Step configuration  Step 1 : Setup default networking for guest VM with NAT  Step 2 : Create Host-only Networking in VirtualBox  Step 3 : Setup secondary adapter for each guest VM  Step 4 : Configure guest VM  Step 5 : Easier access to guest VMs with ‘hosts’ configuration
  • 8. Testing ◈ Host Machine  Ping to all guest Host-only IPs (10.1.2.11, 10.1.2.12 …)  SSH to all guest VM ◈ Guest Machine  Ping to ‘www.google.com’ to make sure external network works well including DNS.  Ping to gateway (10.1.2.1)  Ping to other guest VM.  Check SSH daemon running. (ps –ef | grep sshd)  Check firewall open (default is all open in ubuntu server)
  • 9. References ◈ Reference Sites  http://christophermaier.name/blog/2010/09/01/host-only-networking-with-virtualbox  http://allisterx.blogspot.com/2008/05/additions-and-ssh-access-to-virtualbox.html  http://serverfault.com/questions/308229/virtual-box-host-only-adapter-configuration  http://jackal777.wordpress.com/2012/02/13/internet-access-in-virtualbox-host-only-networking/  http://www.ubuntugeek.com/how-to-set-up-host-interface-networking-for-virtualbox-on-ubuntu.html  http://superuser.com/questions/144453/virtualbox-guest-os-accessing-local-server-on-host-os  http://www.virtualbox.org/manual/ch09.html#changenat