Raspberry Pi Cisco Configuration Device

5 min read Original article ↗

At work we have many routers and switches, and we have highly skilled people who spend a lot of time configuring replacement devices often through a technician’s laptop who is on-site.  I wondered if there was a better way so that only the tech needed to be involved.

Come to find out when an unconfigured Cisco device is first started it will go turn on the auto-install feature. Here is a quick link if you want more info: http://www.cisco.com/c/en/us/td/docs/ios/12_2/configfun/configuration/guide/ffun_c/fcf002.html.

Long story short, when a device (router/switch) first starts up it tries to get an IP address through DHCP, if that DHCP server has the TFTP (150) option set the device will reach out to the IP listed. It will then ask for several named files–I am going to use “network-confg” for this document.  If the device finds this file it will then import the config.  So all we need to make it so anyone can configure the Cisco gear is a server running DHCP and TFTP that anyone can use.  I didn’t want to use their laptop–as installing a DHCP server on a non-technical persons laptop is just asking for trouble–and I wanted it to be affordable.  So the Raspberry Pi came to mind.  This document should walk you through setting up a Pi to apply a configuration to your Cisco gear.

First you need to download the OS https://www.raspberrypi.org/downloads/raspbian/. I did the desktop version as I am not great at Linux.  Here is the link for how to install it for those of you with Windows: https://www.raspberrypi.org/documentation/installation/installing-images/windows.md.  For those of you running Linux I am sure you know Linux better than I do, so have at it.

Most everything will be done on the CLI for this document, just SSH in (default account is Username = pi, Password = raspberry).

Let’s go ahead and upgrade and update the Pi:

sudo apt-get update

sudo apt-get upgrade

DHCP config:

Next let’s install the DHCP server:

sudo apt-get install isc-dhcp-server

Now we need to edit the DHCP config to give it an IP range, and enable option 150 where we will put in the IP address that we will use for the Pi later on (192.168.1.254).  First we open the config file:

sudo nano -w /etc/dhcp/dhcpd.conf

Next just add this to the bottom of the config file:

option voip-tftp-server code 150=ip-address;

option voip-tftp-server 192.168.1.254;

subnet 192.168.1.0  netmask 255.255.255.0 {

 option routers 192.168.1.254;

 option broadcast-address 192.168.1.255;

 pool{range 192.168.1.100 192.168.1.250;}

}

if exists dhcp-parameter-request-list {

option dhcp-parameter-request-list=concat(option dhcp-parameter-request-list,96);

}

Exit and save the config file.

I have had issues getting this service to start on boot-up, so my hack I am sure will make the Linux gurus puke: we are going to tell cron to start it every minute.  If you have a better way please let me know, but this service always errored out for me when I told it to start on startup.

crontab -e

It prompts you for a number, choose “2”.

Paste in:

* * * * * sudo service isc-dhcp-server start

Save and exit.

TFTP config:

First install tftp:

sudo apt-get install xinetd tftpd tftp

Next make the config file:

sudo nano /etc/xinetd.d/tftp

Paste in the following:

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /boot/tftp
disable = no
}

The “server_args = /boot/tftp“ is where you will put the config files. You may be wondering “Why would you put them into the boot folder?”  The answer is: because when the tech plugs the card into his windows machine that is the folder he’ll see.  So let’s go ahead and make that folder in the boot directory.

sudo mkdir /boot/tftp

Next we have to set our IP address.  This is the only thing I did though the GUI, just go up to the network area in the top right of the screen right click and tell it you want eth0’s IP to be 192.168.1.254 with a subnet mask of  255.255.255.0, or there are a million other tutorals on how to set a static IP.

This finishes up the configuration portion of the work, now let’s try it out.  First let’s take a backup of a config and save it to our micro SD card under the tftp folder as “network-confg”.

network-config

Move the Micro SD card to the Pi and start the Pi.  Next plug the Ethernet into a device with no startup config, and start the device.  Next comes the waiting, give it a few minutes.  The switch ports still go though STP so even after it’s fully booting it has to go though work to get working.  Below is a screenshot of a device that has gone through this process.  Please note different models of gear work slightly differently on crypto and write mem, so do your own experimenting to figure out what works.

Line Con 0

You can see the device in action here: https://youtu.be/sqK0Jr64-0g

And here is the documentation links I used to get this up and running.

https://help.ubuntu.com/community/isc-dhcp-server

https://ubuntuforums.org/showthread.php?t=2156287

http://askubuntu.com/questions/629296/how-to-install-and-setup-tftp-server-in-ubuntu-14-10-utopic

http://askubuntu.com/questions/201505/how-do-i-install-and-run-a-tftp-server