I am using VirtualBox khổng lồ create multiple virtual machines running Ubuntu Linux, then configuring them to create a virtual network. This virtual network is then used for testing và demonstrating basic networking và security concepts và technologies. The approach is to lớn create a base virtual machine và the clone it multiple times to create nodes in the network. Each node needs minor configuration, such as setting IP.. addresses and routes for the network interfaces. I have detailed instructions so that hopefully anyone can create their own virtual network.
To make the creation of the virtual network easier & faster, my ayên is lớn automate as many steps as possible. The ultimate goal is that someone can download a base virtual machine image, specify the desired network topology, và then run a program that creates that virtual network. This article describes my current work towards this goal.
Quý Khách đang xem: Tạo virtualbox sử dụng size toàn screen vào windows 8
Currently I am constantly testing và improving the steps lớn automate the virtual network creation. The steps và scripts are poorly designed, implemented and tested. But they work for me và so may be of use khổng lồ others. However I recommover anyone using these instructions be prepared to lớn for things to go wrong – have a backup at least of your base virtual machine.
Prepare the Host
The VirtualBox comm& line interface, VBoxManage, và a mix of Bash shell scripts (và some comtháng Unix/Linux commands) are used khổng lồ automate the creation of the virtual network. VBoxManage is installed when VirtualBox is installed. To run the scripts, Bash shell is needed. Bash is supported on most Unix-lượt thích operating systems, including Linux & OS X. For Windows, Bash can be run using Cygwin. I have developed the Bash scripts using Ubuntu Linux as the host operating. Some quiông xã testing confirmed that worked also in Cygwin on Windows 7. Further testing is needed to ensure they work successfully on other operating systems. If the scripts vị not work on your host, you are stuchồng with using the manual steps.
There are several steps to perkhung on your host computer before you can create a virtual network. The first steps, which apply to lớn all host operating systems, are to:
Unpachồng the downloaded virtual machine inlớn a directory called base & open it in VirtualBox from the thực đơn Machine -> Add…
Now proceed lớn the instructions specific lớn your operating system. A 5 minute test of performing these steps on Ubuntu Linux is below.
I have sầu tested on Ubuntu Linux 12.04 LTS và Ubuntu Linux 14.04 LTS. It”s highly likely other Linux distributions will also work successfully.
I have sầu tested on Microsoft Windows 7. I hope it will also work in Windows 8.
Selecting Packages for Cygwin on Windows
Once Cygwin is installed, start it và you will be give a shell prompt (i.e. terminal). All subsequent commands are run in Cygwin terminal.
The next step is to lớn setup the Subversion repository. After that is complete, there is a small step specific to Windows lớn make VBoxManage available in your path.
Mac OS X
This has been successfully tested on OSX 10.8. Subversion is needed. If you don”t already have it, then it is available via Xcode:
Usernames và Passwords
If you downloaded the provided base virtual machine then the username & password information is:Default user: network; password networkRoot user: root; password networkMySQL admin password: network
If you create the base virtual machine yourself, then you may use the same passwords.
Checkout the virtnet Subversion Repository
mở cửa a terminal và proceed with the following steps. They should work on all host operating systems that tư vấn Bash.
A mix of Bash scripts and accompanying data files are used to automate the creation of the virtual network. These are available on my virtnet Subversion repository. First create a directory called svn in your trang chủ directory.
sgordonhost:~/svn/$ svn checkout https://neftekumsk.com/svn/virtnet/ This creates a directory called virtnet inside the ~/svn directory. Enter it and browse the contents. There are two sub-directories that are important at this moment:
~/svn/virtnet/bin/host/: contains the Bash scripts for running on the host.~/svn/virtnet/data/topologies/: contains the interfaces files that need to lớn be copied to lớn each virtual machine that is created.
There is one more change to make. The permissions of a SSH private key file must be modified khổng lồ be readable only by the user. To vì chưng so, type:
sgordonhost:~/svn/$ chgrp -R Users ~/svn/virtnet/data/defaults/root/.sshIf you are using a different locale (e.g. French, German) then the group “Users” above sầu may be different. See the answers khổng lồ the questions on Superuser và Stackoverflow for more details.I have prepared some topologies that can be created automatically (you can see images of the topologies in the directory ~/svn/virtnet/data/images/). I describe how the topologies work và how to lớn create your own towards the end of this article.
Microsoft Windows (Cygwin) Only
If your host operating system is Microsoft Windows, you should now thiết lập the path to VBoxManage by executing the following in the Cygwin terminal:
sgordoncygwin $ ln -s “/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe” VboxManageHere is a screenshot of using Cygwin lớn checkout the Snước ta repository and then mix the path và links lớn VBoxManage (click on it to lớn zoom in).
Stoàn quốc Checkout và Setting the Path in CygwinYou will need khổng lồ re-run the last two commands everytime you start Cygwin. To avoid this, you can add the following two lines lớn the tệp tin .bash_profile:
PATH=$PATH:.ln -s “/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe” ~/svn/virtnet/bin/host/VboxManage
Create the Virtual Network
There are a number of pre-created topologies that you can choose from to lớn quickly build a network. See them here. For this demo I”ll use topology 5 which contains three nodes:
The rectangles in the topology diagram labelled neta and netb are switches created automatically by VirtualBox – they are not virtual machines that we need khổng lồ create. The IPhường. addresses in all cases start with 192.168.. For example, interface eth1 of node 1 has IP. address 192.168.1.11.
Enter the directory containing the Bash scripts:
sgordonhost:~$ cd ~/svn/virtnet/bin/host/Now run vn-createtopology with the topology number as the first (và only) parameter:
sgordonhost:~/svn/virtnet/bin/host$ bash vn-createtopology 5This is the main script, which in turn calls others. You will see some output (hopefully) indicating that the virtual machines for the nodes are created. You may be prompted for a password for the root user of the base virtual machine (depending on whether or not you thiết đặt public/private keys for SSH).
If all goes well, then the new virtual machines, one for each node in the topology, will be created in VirtualBox. You can now start them & test your network. A quiông xã way to start a VM và login to lớn it is to use the provided script vn-ssh. It takes a parameter as an input, which indicates the node number to lớn start and login lớn. For example, to lớn start node 1:
sgordonhost:~/svn/virtnet/bin/host$ bash vn-ssh 1It may take a minute or so, but eventually you should be logged in lớn node 1. Repeat for other nodes in another terminal, e.g. bash vn-ssh 2 (make sure you are in the correct directory, i.e. ~/svn/virtnet/bin/host).
If you encounter problems in setting up and using virtnet, then first see the Troubleshooting page. If that doesn”t solve sầu your problem, I recommkết thúc sending me an tin nhắn with a screenshot of the error.
One approach to lớn using these scripts for creating virtual networks is:
Run vn-createtopology lớn create the desired topology of nodesUse the virtual networkWhen finished with the virtual network, delete the node virtual machines (when VirtualBox prompts, select to delete all files)Repeat from step 1.
You should delete the automatically created nodes before creating a new virtual network (or at least rename them) since the new network will use the same node names, e.g. node1, node2, node3.
The base virtual machine is not used in the virtual network. It is cloned to create the nodes in the network. Keep the base up lớn date (in terms of required software packages và configuration) so when you create the virtual network the nodes will be up to date.
Creating Your Own Topology
See the README.txt tệp tin in the data/topologies/ directory of the Scả nước repository for an explanation of how to create your own topology.