I have been working to learn how to use Python to automate interactions with network devices. Due to what I have in my lab and the fact that we have GNS to model Cisco Networks I started with IOS. In order to really test out the automation scripts I have been building, I felt it was necessary to run them against at least ten devices to make sure they would scale out and recover well from errors. In order to do that I had to build out a 10 device lab. This is how I did it.
- GNS3 Installed
- TunTap Installed
- Copy of IOS for Cisco 3725 router that supports SSH I am using c3725-jk9s-mz.123-23
- Download this GNS3 SetupFile
- Have gone through this Post, and have the ping script and host file local on your computer.
What we are going to accomplish:
- Setup and IP ten TAP connections on OSX to communicate directly to routers via SSH
- Setup ten 3725 routers with direct connection to a TAP interface in OSX.
When we are done the network should end up looking like this:
I am doing things this way because the local workstation will know how to route to each device as a connected network. This lab is simply for testing the scale of a Python script. So why waste the time and complexity on a fully routed lab. In the future we will do other labs to show how to deal with timing of changes a to not break a production network but for now that is not the goal.
First things first we are going to have a set of IP Addresses to assign to our TAPs and to FA0/0 on the virtual routers. For me I chose 10.0.0.0/8 and then broke them down into /30 networks. This is the addressing for this lab setup. From there we have to do things in a very specific order for the local OSX interfaces to work right.
1. Start GNS3 as Root user. You will do this from the terminal not the GNS3 Icon.
2. Now got to the pytest.zip file you downloaded earlier and extract it.
3. From the GNS3 GUI (Should have spawned after step #1) got to File Open and navigate to the file you extracted pytest.zip. Inside the file will be pytest.gns3 select and click open. You should see the diagram above in the window with the routers turned down.
4. Go to a terminal window and run ifconfig, you should now see interfaces tap0 – tap9 as well as your normal interfaces.
5. In the terminal window run the following commands to address the TAP Interfaces.
ifconfig tap0 10.0.0.1/30 up
ifconfig tap1 10.0.0.5/30 up
ifconfig tap2 10.0.0.9/30 up
ifconfig tap3 10.0.0.13/30 up
ifconfig tap4 10.0.0.17/30 up
ifconfig tap5 10.0.0.21/30 up
ifconfig tap6 10.0.0.25/30 up
ifconfig tap7 10.0.0.29/30 up
ifconfig tap8 10.0.0.33/30 up
ifconfig tap9 10.0.0.37/30 up
You can download this file here.
6. Go to File, Import/Export Devices Configs, Choose Import from a Directory. Navigate to the files you extracted pytest.zip. Then drill down through project-files, Configs and click choose.
7. Go to Edit, Select All, then press the green play button to start your routers.
8. Once you are sure the routers are up run the ping tool from this Post. If you use the provided host file everything will match up.
That is it. You have a 10 node network that you can test your Python scripts against. I will be publishing the next few parts of my What Did you Expect Series and this lab will play a key part as we move forward.
Big thanks to Fixed by Vonnie who provide this great article on setting up TunTap on OS for GNS3.