This blog describes how to install and run a CSR1Kv on Ubuntu 16.04.1 LTS. It is based on the CSR1Kv 16.03.01 release.
My goal was to test the NETCONF and RESTCONF management interfaces on the CSR1Kv.
Note that there are many ways to skin a cat, as the saying goes. This one, amongst many others, worked for me under these circumstances, for my specific needs. Hopefully you can derive something useful here also.
These instructions are specific to my development environment, which looks like this:
- MacBookPro development client 16GB RAM running OS X 10.11.6
- ThinkPad W530 28GB RAM runnng Ubuntu 16.04.1 LTS
- Four port ADSL router serving DHCP on 192.168.1.0, to which the two laptops are physically connected.
The general idea is that I develop on the MBP, where I would be running Python scripts, or ODL, for example. The W530 is a server running the devices. The ADSL router serves up addresses to everything, so there is full connectivity all round.
Setting up the Ubuntu W530
I start with a fresh install of Ubuntu on the W530. I did that via a boootable USB as described here.
Note that I used the USB to boot the W530 and install Ubuntu there, not on the MBP as the instructions say. I created a user "cisco" with password "cisco", just to keep life simple and consistent.
Note that, once the W530 is finally booted to Ubuntu, and you have its address, you can access it from the MBP using SSH. First, though, you need to install SSH on the Ubuntu W530 laptop like this:
sudo apt-get -y install openssh-server
In general you can now can use SSH with X forwarding, and SFTP to transfer files. Note that you need to install Quartz (https://www.xquartz.org) on OSX.
SSH with X forwarding works like this:
ssh -X cisco@<address of W530>
Then you need to install Qemu, KVM, libvirt and associated tools, and bridge-utils. Then you need to add the $USER, i.e. the `cisco` user to the `libvirtd` group. Then you need to reboot to start the `libvirtd` daemon.
sudo apt-get -y install qemu-system qemu-kvm libvirt-bin virtinst virt-manager bridge-utils
sudo adduser $USER libvirtd
Setting up Networking on the Ubuntu Machine
In my case, I wanted to use bridged networking so that all of my devices, physical and virtual, are on the same network with addresses coming from the DHCP server on the ADSL router. So, the remainder of these instructions are based on bridged networking.
To set up bridged networking and allow Qemu to use that you need to do this (note, it is perfectly possible that the libvirt method for creating the CSR1Kv does not need this, but this methodology evolved after some experimentation down different paths, and this does work):
sudo mkdir -p /etc/qemu
sudo sh -c "echo \"allow br0\" > /etc/qemu/bridge.conf"
sudo chmod u+s /usr/lib/qemu/qemu-bridge-helper
The next part depends on the networking configuration:
enp0s25 Link encap:Ethernet HWaddr 3c:97:0e:c9:dc:43
inet addr:192.168.1.39 Bcast:192.168.1.255 Mask:255.255.255.0
Note the enp0s25 interface. You might expect to see `eth0`, but not in my case.
Now you need to add a bridged interface, br0, to /etc/network/interfaces so that it looks like this (you will need to edit the file as sudo, e.g. sudo vi /etc/network/interfaces):
# interfaces(5) file used by ifup(8) and ifdown(8)
iface lo inet loopback
iface br0 inet dhcp
Then you can reboot, or just restart networking, like this:
sudo /etc/init.d/networking restart
Note that I used a physical ethernet interface above. I also tried a WiFi interface, but that did not work.
Setting up the CSR1Kv
The CSR1Kv image files are available from here.
Click on "Expand All" on the left, and look for the "Denali-16.3" item in the tree (under "Latest" at the time of writing).
I used the ISO for this process, following instructions derived from here.
Start the Virtual Machine Manager with the command virt-manager. In my case, the first time I do that, I get an error message. The second time is fine. Sometimes I have to try sudo virt-manager. This has not either worked or failed consistently, but it does eventually work.
The UI looks like this (you can also see some of my earlier efforts).
The screen symbol in the top left of the UI will start the process to create a new VM. Choose the "Local install media ..." as illustrated below and click on "Forward".
In the "New VM" dialog that appears, select the CSR1Kv ISO file that you downloaded earlier and then click on "Choose Volume".
Then set the RAM and CPUs as shown below. Note that this is the minimum, and so you might need more in your case.
The next step is to enable storage. The defaults are suitable here. as shown below. Click on "Forward".
The add a suitable name, and select "Customize configuration before install", as shown below, and check the "Network selection", which should default to the "br0" that you created above. Then click on "Finish".
The next dialog, illustrated below, allows you to add a serial device for telnet access, by clicking on the "Add Hardware" button.
Then click on "Finish", and then "Begin Installation", with the green tick.
Then you should expect to see a console window appear, which will display the various messages that appear at the device boots up.
Eventually, and you may need to press "Return" in the console a few times to see this, you should see a Router> prompt. You can enter "enable" mode, with en and have at it.
You will, in this case, have a single, management (in effect), interface which will have been assigned an IP address via DHCP. For my purposes, that meant that the router was reachable via that address for testing management APIs. If you need other network configurations, then you will need to experiment with creating additional bridged interfaces.