Of course, the first thing you will have to do after purchasing a used network switch is resetting it to factory settings and it's really straight forward when it comes to Cisco switches, I will write about that later on in a new post.
Then, you definitely want to configure it to work in your own network with specific settings because it is a smart switch for which you want to reach its command line through the serial console interface and that's what I am going to explain in details today.
Since I am labeling this as a Homelab tutorial where we mostly like to run Linux on our servers and desktop computers, I would rather explain through steps specifically on that operating system and its widely known distributions including:
- Debian based distributions like Ubuntu, Elementary OS, Mint, etc.
- RPM Package Manager (RPM) based distributions like CentOS, Fedora, etc.
- Pacman Package Manager based distributions like Arch and Manjaro.
Install Minicom from Package ManagerThat's why I've been mentioning each distribution matched with its package manager. We need to install the package for "Minicom" which is described by the maintainer as follows:
Minicom is a text-based serial port communications program. It is used to talk to external RS-232 devices such as mobile phones, routers, and serial console ports.
Now, just figure out what is the package manager for your Linux distribution and open up a terminal on your screen.
linux:$ sudo -s linux:# apt-get update && apt-get install minicom linux:# exit
linux:$ sudo -s linux:# apt-get update && yum install minicom linux:# exit
linux:$ sudo -s linux:# apt-get update && pacman -S minicom linux:# exit
That's about it, you should now be ready to go.
Connect RJ45 Console Port to Linux ComputerIn order to connect with the RJ45 console port on the back of your Cisco switch you have two options.
RS232 to RJ45This is actually the cable that comes packed originally in the box when you buy the switch, if you don't have one of these just buy from AliExpress or Amazon. I got mine from this seller on that link.
This won't work if your Linux computer motherboard doesn't have an RS232 DB9 COM Serial Port which leaves you with the second option.
USB to RJ45This might be the ideal choice for many of you, because every motherboard will definitely include some USB ports. I also happen to have one of these and I bought it from this seller on that link.
Configure Minicom to Work with Cisco SwitchOkay, it's time to create a Minicom configuration file.
Find Serial Connection PathThe moment you connect the switch from its RJ45 console port to your Linux computer, open up a terminal and enter.
linux:$ dmesg | grep tty
Let me show you a sample output if you are using an RS232 to RJ45 cable.
[ 0.000000] console [tty0] enabled [ 0.726168] 00:08: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
In the other hand if you are using an USB to RJ45 cable, you should get something like this.
[155582.296838] usb 3-2: FTDI USB Serial Device converter now attached to ttyUSB0
What you are looking for is the text marked with white colour as shown in the samples above. Now, accordingly for each output sample the serial connection path is:
Create Configuration FileAgain, open the terminal and enter.
linux:$ sudo minicom -s
You will be greeted with the main menu list for Mnicom now go to
Configuration → Serial Port Setupand you should see another menu to define which serial port path you are going to use.
Aon your keyboard and enter the serial connection path that you have noted from the previous step which is for example something like this
/dev/ttyUSB0in my case, then press
Enterto go back to the serial port setup menu.
Eon your keyboard, resulting in another menu for
Bps/Par/Bitsrate, from that menu press
Cto set the rate to
9600 8N1then press
Enterto go back to the serial port setup menu.
Last but not least, I prefer to enable the
Hardware Flow Controlso just press
Fon your keyboard and toggle that option to
Enterto go back to Minicom main menu.
In the main menu choose the
Save setup asoption and give it a name, in my case I named it as
ciscothen finally press
Enterand you have successfully created a Minicom configuration file to connect with your Cisco switch.
Communicate with Cisco Switch Serial ConsoleBasically, every time you want to communicate with your Cisco switch you will only have to load the configuration file that you have created for Minicom with a simple single command from the terminal.
linux:$ sudo minicom cisco
Notice that I am running Minicom calling the "cisco" configuration file that we created earlier, if everything is done correctly press "Enter" right after you run that command and you will be presented with something like this:
Welcome to minicom 2.7.1 OPTIONS: I18n Compiled on Aug 13 2017, 15:25:34. Port /dev/ttyUSB0, 02:35:45 Press CTRL-A Z for help on special keys Switch>
If you can see the hostname "Switch" then that indicates it has connected successfully, enter any command to the switch like
show interfacefor example, and see if you are getting a response to make sure.