Friday, March 18, 2022

booting cisco iosxrv in virtualbox

abstract

Cisco has some virtual images of their iosxr system (iosxrv), which aren't very easy to use.
This is how I got iosxrv to work on virtualbox.
The trickiest parts were that the specs fixed/imported by image are pretty large, so you have to scale them down to make it work. And that virtualbox apparently can't find the interface to do ssh forwarding so you can actually connect to the device (is my GUI client buggy?... idk, but found it in the xml file you're not supposed to edit manually, but that works if you do anyway).


overall steps

1. import ova image

2. change image specs/configs

3. boot image 

4. (on X) create default user

5. (on X) setup ssh server and interface

6. confirm you can ssh with a localhost high port


Prerequisites

1. virtualbox

2. image files (ova files)

3. an X working system (connect from a GNU/Linux system on your client end, or install a windows client)

I did this on my debian server, on both a physical machine, and a VM, worked just fine.


steps


# ssh to the VM with the -X option, so you can run X programs from the server
ssh -X YOUR_SERVERS_IP_ADDR


# sample for 6.5.2. Please replace VM/image name as needed
# import image

VBoxManage import xrv9k-fullk9-x.vrr.vga-6.5.2.ova


# change name
VBoxManage modifyvm com.cisco.ios-xrv9000 --name iosxrv6.5.2


# change default options that make VM unbootable
VBoxManage modifyvm iosxrv6.5.2 --vtxux on
VBoxManage modifyvm iosxrv6.5.2 --ostype Linux_64
VBoxManage modifyvm iosxrv6.5.2 --cpus 6
VBoxManage modifyvm iosxrv6.5.2 --memory 7096
VBoxManage modifyvm iosxrv6.5.2 --vram 10
VBoxManage modifyvm iosxrv6.5.2 --longmode on
VBoxManage modifyvm iosxrv6.5.2 --graphicscontroller vmsvga


# add ssh port forwarding settings from virtualbox
VBoxManage modifyvm iosxrv6.5.2 --nic6 nat

# Change local port ("5801" here) and connection name (ssh_652) per VM.
# The rest stays the same
VBoxManage modifyvm iosxrv6.5.2 --natpf6 ssh_652,tcp,127.0.0.1,5801,10.0.7.15,22


# check mac address
grep "Adapter slot=\"5\"" ~/ ~/VirtualBox\ VMs/iosxr\ 6.5.2/*box # replace dir as necessary

#    <Adapter slot="5" enabled="true" MACAddress="XXXX" cable="true" type="XXXX">
# we'll use this to confirm on the VM side later that the right interface
# is being addressed

# boot once with X on
# it will be super slow (like 10m?), but it should boot. And ask you for your
# new root username/password

VBoxManage startvm iosxrv6.5.2


##################
# on the X window
##################

# create the new user following the prompt's instructions


# name the device, and setup the ssh server
conf t
hostname iosxr652
commit
exit

crypto key generate rsa
conf t
ssh server v2
line default transport input ssh
commit
exit

# setup interface for ssh forwarding
show int MgmtEth0/RP0/CPU0/0

# confirm mac address is the right one for our port forward
# you should get somewhere around the top a string representing the mac address
# check it matches the string got in the above step "check mac address"
# if not, to check which MAC address matches the mgmt interface, and do the NAT
# ssh port settings to that one instead

conf t
interface MgmtEth0/RP0/CPU0/0
 ipv4 address dhcp
 no shutdown
commit
exit
exit


# confirm interface is up and has an IP address assigned
show int MgmtEth0/RP0/CPU0/0

# we're assuming the IP address is 10.0.7.15
# if not, change NAT ssh forwarding settings accordingly

########################
# outside the X window
# (on your regular terminal)
########################

# (on the host running virtualbox)
ssh random_admin@localhost -p 5801 # replace username as necessary

# you should be able to login
# click the close button on the X window with the VM, and choose "shutdown VM"

# start VM again, with no X window
VBoxManage startvm --type headless iosxrv6.5.2

# after 10m or so, confirm you can ssh again
ssh random_admin@localhost -p 5801

# that's it!

# to stop:
# VBoxManage controlvm iosxrv6.5.2 poweroff 


No comments:

Post a Comment