Vous êtes sur la page 1sur 26

Simulating Networks with GNS3 and Virtualbox William Howe

04/04/2011

1|Page

Contents
Introduction: GNS3 and Virtualbox ........................................................................................................... 3 Creating the network with GNS3 .............................................................................................................. 4 Basic Router Configuration of the network ............................................................................................ 12 Adding virtual machines to the network ................................................................................................ 15 Confirming virtual machine communication on the network ................................................................ 19 Conclusion and Further Reading ............................................................................................................. 25 Resources ................................................................................................................................................ 26

2|Page

Introduction: GNS3 and Virtualbox


Having the ability to build a virtual test network is a great way to test network design, planning, implementation, and configuration testing. This documentation shows how to use GNS3 (Graphical Network Simulator 3) to create a virtual network, but also integrate virtual machines installed within Virtualbox as hosts on the network. Having virtual machines as hosts creates a more real network that more closely simulates the real thing. Assumptions The documentation assumes the following pre-requisites: GNS3 is installed. (http://www.gns3.net/download) Virtualbox is installed. (http://www.virtualbox.org/wiki/Downloads) 3 Linux VM's are installed. Two will be workstations and one will act as a web server running apache. The distribution does not matter, but the examples used in this documentation are CentOS. (http://www.centos.org/) This distribution was chosen as it is free and closely follows the packages and release cycle of the commercially available Red Hat Enterprise Linux distro. Access to a Cisco IOS or two. These can be obtained from Cisco.com if you have a Technical Support Service Agreement or from any actual Cisco router that you own. (Copy the IOS from flash to a TFTP server on your computer)

3|Page

Creating the network with GNS3


GNS3 needs to be opened with administrative privileges to perform some of the advanced configuration that will happen later in the examples. At a terminal, type sudo gns3. When GNS3 is opened, a New Project dialog box opens up. Here, you name the project and select the directory to store all the data in for that topology. Select Save nvrams... and Save IOS.. to preserve all virt ual router settings and configuration for the next time you open the program up with that project.

Figure 1: Starting a new project

Now that a project has been opened up, the topology needs to be built. Before the objects on the left side can be dragged to the center area to create the network map, a Cisco IOS needs to assigned to the object. To do this, select Edit > IOS Images and Hypervisors.

Figure 2: IOS images and hypervisors

4|Page

Under the IOS Images tab, there will be a Settings section. Find your IOS image file by clicking the ... button and browsing to it.

Figure 3: Editing the IOS images

One very important step that is hard to forget, is that since GNS3 is a simulated environment, it has trouble sometimes uncompressing Cisco IOS images within its virtualized environment. If this is the case, when you get around to starting up the simulated router, a ton of garbage will fly across the console screen and the router will crash. To fix this issue, you will need to uncompress the .bin IOS image. To do this, simply open up a terminal, change directories to the path where the IOS images are located and type unzip ciscoIOS.bin. (Replace ciscoIOS.bin with the actual name) Use this IOS image instead and GNS3 should have no problem loading the image.

5|Page

Figure 4: Unzipping an IOS

In this example, an unzipped 2600 router IOS has been selected. No base configuration will be used, the platform was automatically selected as a c2600 (which is correct), and all other options are left at default. Click Save in the lower left and the path to the image along with the model is saved in the top section.

6|Page

Figure 5: Saving the selected IOS image

After the IOS is saved, close the IOS images and hypervisors window. Now, find the type of router that was added on the left under Node Types. (In this example, the Router c2600) Left-click and drag the router to the middle blank pane. The first node is now in the topology!

7|Page

Figure 6: Adding a Router to the Topology

Before device configuration starts, a simple example topology is built using another router to act as the border router, a switch(Ethernet switch) to connect to the internal router (our first router), and a cloud (last Node) up top to connect to the border router. (This will act as our Internet cloud) Three additional clouds are added as place holders, which will be configured as the virtual machines later on. I have also renamed the devices by right clicking them and selecting Change the hostname.

8|Page

Figure 7: Building the Topology

We will need a third port on our inside router for the web server virtual machine. Right click the R_Internal router and click Configure. From there, select R_Internal and then the Slots tab. From here, you can add adapters just like a real router. Click the drop down for slot 1and select NM1FE-TX for a fast ethernet slot. Click apply and ok. (If you get a message about restarting the router for changes to take place, just press the red stop button and then the green start arrow to start the devices again)

9|Page

Figure 8: Adding a Fast Ethernet Module

Time to make some physical connections. Find the Add a link icon and left -click it. (Three to the left of the console icon.) Select FastEthernet, left-click the R_Internal router, and then the Switch. A new connection is made. Click the R_Internal router again and then click the R_Border router to make another connection. When you are done making connections, click the red circle with an X that has replaced the add a link icon to stop.

10 | P a g e

Figure 9: Making Physical Connections

11 | P a g e

Basic Router Configuration of the network


In this section, the routers will be configured with a very basic setup in order to facilitate communications. Note that no security is configured to keep this section brief. On the right under Topology Summary, a red circle means the device is off. Left-click the big green arrow to power on all devices. Click the console icon up top (left of the green start arrow) to open a console connection to all devices.

Figure 10: Powering on and Connecting to the Routers

Since the IOS is not compressed, there is not waiting for decompression. Select the R_Internal router. Press 'Enter' and then 'no' for the initial configuration dialog. Enter again gives you a command prompt. The following configuration is entered: enable config t hostname R-Internal int fa 0/0 ip address 192.168.5.1 255.255.255.0 no shut 12 | P a g e

int fa 0/1 ip address 192.168.15.1 255.255.255.0 no shut int fa 1/0 ip address 192.168.10.1 255.255.255.0 no shut exit router eigrp 1 network 192.168.5.0 0.0.0.255 network 192.168.10.0 0.0.0.255 network 192.168.15.0 0.0.0.255 network 192.168.20.0 0.0.0.255 Ctrl+z wr A similar configuration is done for the R_Border router: enable config t hostname R-Border int fa 0/0 ip address 192.168.15.2 255.255.255.0 no shut int fa 0/1 ip address 192.168.20.1 255.255.255.0 no shut exit router eigrp 1 network 192.168.5.0 0.0.0.255 network 192.168.10.0 0.0.0.255 network 192.168.15.0 0.0.0.255 network 192.168.20.0 0.0.0.255 Ctrl+z wr Both routers should now be configured with basic communication and be able to ping each interface address. The topology map in GNS3 has also been updated to include text notes containing the IP address scheme used. To add a text note, click the notepad icon to the right of the start, pause, stop icons.

13 | P a g e

Figure 11: Updated Topology

14 | P a g e

Adding virtual machines to the network


Before adding virtual machines to the network, Virtualbox network settings will need to be modified. The following steps setup Virtualbox to match the IP Address scheme that was setup in GNS3. Open Virtualbox and click on the File > Preferences > Network on the left. Select vboxnet0 and then the screwdriver for edit. Change the Ipv4 address to: 192.168.5.1 and subnet mask to 255.255.255.0. Uncheck Enable Server on the DHCP tab. Click Ok. Now, create another host only network by clicking the + symbol to a dd. For the Ipv4 address, put: 192.168.10.1 and subnet mask: 255.255.255.0. You should now have two host only networks, vboxnet0(192.168.5.0) and vboxnet1(192.168.10.0).

Figure 12: Virtualbox Host-Only Network

Select one of the Workstation virtual machines and click Settings. Click Network and ensure that Adapter 1 is set as Host-only and vboxnet0. Do the same for the other Workstation. Put the web server virtual machine on the host only network vboxnet1. 15 | P a g e

Figure 13: Network Settings for Workstation1 and 2

Now it is time to add the virtual machines to the GNS3 network, which is where those clouds come in. Right-click the Workstation1 cloud and click Configure. Under the NIO Ethernet tab, there are options for adding Ethernet adapters. Click the drop down box under Linux Ethernet NIO, find the same network that was in Virtualbox for the 192.168.5.0 network (vboxnet0), select it, and click add. Apply and Ok to close the box.

16 | P a g e

Figure 14: Editing the GNS3 Clouds

Create a link from Workstation1 cloud to the switch. Repeat adding the Linux Ethernet NIO for Workstation2 using vboxnet0 (since they are both on the same network segment). Create a link from Workstation2 cloud to the Switch. When editing the Web_Server cloud, ensure the Linux Ethernet NIO vboxnet1 network is added (since it is on the 192.168.10.0 network). Create a link from the Web Server cloud to the R_Internal router. The topology should look like Figure 3-4 when complete.

17 | P a g e

Figure 15: Connected Topology

18 | P a g e

Confirming virtual machine communication on the network


Now to get some communication going! Start all the virtual machines in Virtualbox. Assign static network adapter settings to the virtual machines like so: Name Workstation1 Workstation2 Web_Server IP Address 192.168.5.2 192.168.5.3 192.168.10.2 Subnet Mask 255.255.255.0 255.255.255.0 255.255.255.0 Default Gateway 192.168.5.1 192.168.5.1 192.168.10.1

To do this in CentOS, click System > Administration > Network. Click Edit to edit the eth0 adapter. Next, click the circle that says Statically set IP addresses.

Figure 16: Static IP in CentOS (Workstation1)

Click Ok, then File > Save. A pop up box informs you to restart the network service or the computer. To restart the network service click: System > Administration > Services. Scroll down to network, select it, and click Restart. 19 | P a g e

Figure 17: Restarting the Network Service in CentOS

Finally! Testing can begin! From the console of the R-Internal router, ping the following: 192.168.5.2 (Workstation1), 192.168.5.3 (Workstation2), and 192.168.10.2 (Web Server). If instructions were followed properly, all should be successful.

20 | P a g e

Figure 18: R-Internal Router Pinging Workstation1, 2, and Web Server

For more testing, open a terminal on the Workstation1 virtual machine. Ping 192.168.5.3 (Workstation2), 192.168.5.1 (R-Internal gateway interface), 192.168.20.1 (R-Border far outside interface. This shows that inter routing is working), and 192.168.10.2 (Web Server).

21 | P a g e

Figure 19: Workstation 1 Pinging Workstation 2 and R-Internal gateway

22 | P a g e

Figure 20: Workstation 1 pinging R-Border interface and Web Server

One last test is on Workstation1, open a web browser, and in the address bar type: 192.168.10.2 (Web Server). The Apache Web Server test page should open up! If it did not, ensure that the httpd service on the web server has been started. (System > Administration > Server Settings > Services. Scroll down to httpd, select it, and click start)

23 | P a g e

Figure 21: Workstation 1 Accessing the Web Server

24 | P a g e

Conclusion and Further Reading


That wraps it up for a good introduction on using GNS3, Cisco IOS, and Virtualbox in a simulated environment. For more information on how to connect the R-Border router to the Internet Cloud and bridge that connection through your desktop computer to the Internet, visit: http://joshatterbury.com/tutorials/configuring-dynamips-to-use-a-linux-tap-interface/

25 | P a g e

Resources
Altbiz. (2010, February 03). Gns3 lab with virtualbox. Retrieved from http://altbiz.wordpress.com/2010/02/03/gns3-and-virtualbox/ Grossmann, J. (2010, December 12). Gns3 graphical network simulator. Retrieved from http://www.gns3.net/ Hughes, J, Singh, K, Perrin, J, Angenendt, R, & Guay, P. (2010, May 14). Centos: the community enterprise operating system. Retrieved from http://www.centos.org/ Kaage. (2009, September 06). Howto connect vmware virtual machine to your lab in gns3. Retrieved from http://www.gns3.net/phpBB/topic1139.html?sid=11ed17c29a256bfb64796d1947916f93 Lammle, T. (2007). Ccna: cisco certifed network associate study guide sixth edition. Indianapolis, Indiana: Wiley Publishing, Inc.

26 | P a g e