• Skip to content
  • Skip to footer

Packet6

San Francisco Bay Area Wi-Fi Professional Services

  • About Us
  • Blog
  • Services
  • Case Studies
  • Contact Us

featured

Configuring Your Raspberry Pi As A Console Server

November 11, 2013 by Rowell Dionicio 5 Comments

You get very excited once you get your own physical lab of routers and switches going. You just can’t wait to start managing and configuring switchport security, spanning-tree, etc. And then you get tired of having to move the console cable from one switch to the other. And you don’t have the ability to play with your lab remotely. Ugh.

Initially, I was going to buy into some sort of console server. Either utilize an old 2500 router or look at OpenGear. But why not use an RPi which would cost less than $100! That just made me happy. And from there I could access my lab anywhere!

My tutorial is very similar and I’ve included my experience below.

What you will need:

  • Raspberry Pi
  • USB to 4 Port Serial Cable

I purchased my USB to serial cable on Amazon. Wasn’t cheap but it works.

USB to Serial

To get started, I installed Raspbian. Download the latest Raspbian image and extract the zip file. You can use win32diskimager-v0.9-binary to load the image to your SD card.

Go through the initial setup of Raspbian and be sure to enable SSH. Before accessing the RPi server remotely, I had to configure the Ethernet interface:

sudo nano /etc/network/interfaces

This is my following static configuration:

iface eth0 inet static
address 10.1.10.250
gateway 10.1.10.1
netmask 255.255.255.0
network 10.1.10.0
broadcast 10.1.10.255

Save that sucker and reboot for good measure

sudo reboot

I’d like to change the hostname from raspberrypi to CONSOLE:

sudo nano /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 CONSOLE

Then modify the hostname file:

sudo nano /etc/hostname
CONSOLE

Now moving on to the actual console portion of this project. We’ll use Ser2net which allows you access the serial ports via telnetting into the RPi.

wget http://downloads.sourceforge.net/project/ser2net/ser2net/ser2net-2.9.1.tar.gz
 tar -xzvf ser2net-2.9.1.tar.gz
 cd ser2net-2.9.1/
 ./configure
 make
 sudo make install
 make clean

Now lets find out where our USB to Serial is connected:

pi@CONSOLE ~ $ dmesg | grep tty
 [ 0.000000] Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0xe bcm2708.serial=0x43e1602e smsc95xx.macaddr=B8:27:EB:E1:60:2E sdhci-bcm2708.emmc_clock_freq=100000000 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
 [ 0.000000] console [tty1] enabled
 [ 0.585230] dev:f1: ttyAMA0 at MMIO 0x20201000 (irq = 83) is a PL011 rev3
 [ 0.916712] console [ttyAMA0] enabled
 [ 6.574040] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0
 [ 7.049168] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB1
 [ 7.232239] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB2
 [ 7.392448] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB3

My RPi recognized all the connectors but the actual device is connected to ttyUSB0.

Let’s edit the ser2net configuration to get things going. The following is my configuration for each serial connection:

sudo nano /etc/ser2net.conf

BANNER:banner:CONSOLE LAB Terminal Server TCP port p device d serial parms srn

TRACEFILE:tr1:/var/log/ser2net/p-Y-M-D-H:i:s.U
4001:telnet:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT banner tr=tr1 timestamp

TRACEFILE:tr2:/var/log/ser2net/p-Y-M-D-H:i:s.U
4002:telnet:0:/dev/ttyUSB1:9600 8DATABITS NONE 1STOPBIT banner tr=tr2 timestamp

TRACEFILE:tr3:/var/log/ser2net/p-Y-M-D-H:i:s.U
4003:telnet:0:/dev/ttyUSB2:9600 8DATABITS NONE 1STOPBIT banner tr=tr3 timestamp

TRACEFILE:tr4:/var/log/ser2net/p-Y-M-D-H:i:s.U
4004:telnet:0:/dev/ttyUSB3:9600 8DATABITS NONE 1STOPBIT banner tr=tr4 timestamp

ser2net-config
Save that file and lets make sure Ser2Net starts up automatically:

sudo nano /etc/rc.local

[Read more…] about Configuring Your Raspberry Pi As A Console Server

Saving Your Putty Sessions To A Log File

October 24, 2013 by Rowell Dionicio Leave a Comment

Putty is a widely used, free, tool to SSH/Telnet/Console/etc into a network device. I can’t recall how many times I’ve burned myself because I fat-fingered the keyboard and then lost my connection to the network device or misconfigured an interface and not realize it for a couple of days. Or what if you wanted to remember what you did a couple of months ago on a switch?

Putty allows you to log each of your sessions. It has saved my bacon so many times.

Here’s how to configure it. First, highlight the Default Settings:

Putty's Default Settings

Then on the left pane, click on Logging under Session.

Under the Session Logging section, select “All session output”
For the log file name, use this structure: &H-&Y&M&D-&T.log

&H – This will append the hostname of the device to the front of the file. I add a dash after this to separate it from the dates.

&Y&M&D – This adds the year, month, and day. Add a dash afterwards to separate it from the time.

&T – This adds the time you logged into the device. Because you may log into the same device multiple times per day, this is a good way to log each session separately.

Click on browse to save it to a specific location. Your log file will then look like: 192.168.1.1-20131024-075505.log

Simple!

Configuring session logging in Putty

Now go back to the Session window, click on Default Settings, and click Save. So next time you open Putty or create a new saved session, it will create the log file.

Let’s see it in action. I’m going to create a new saved session for the ATT Looking Glass route server:

Creating a Saved Session in Putty

Let’s take a look at Google’s BGP routes

Image of Google's BGP Routes

Example Putty Log

Here is the contents of that log:

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2013.10.24 07:58:42 =~=~=~=~=~=~=~=~=~=~=~=
-------------- route-server.ip.att.net ---------------
---------  AT&T IP Services Route Monitor  -----------

The information available through route-server.ip.att.net is offered
by AT&T's Internet engineering organization to the Internet community.

This router maintains eBGP peerings with customer-facing routers
throughout the AT&T IP Services Backbone:

IPv4:
12.123.21.243  Atlanta   12.123.133.124 Austin    12.123.41.250  Cambridge
12.123.5.240   Chicago   12.123.17.244  Dallas    12.123.139.124 Detroit
12.122.83.238  Denver    12.123.134.124 Houston   12.123.29.249  LA
12.123.1.236   New York  12.123.33.249  Orlando   12.123.137.124 Philly
12.123.142.124 Phoenix   12.123.145.124 SanDiego  12.123.13.241  SanFran
12.123.25.245  St.Louis  12.122.125.224 Seattle   12.123.9.241   WashDC

IPv6:
2001:1890:FF:FFFF:12:122:124:12   Atlanta
2001:1890:FF:FFFF:12:122:127:66   Chicago
2001:1890:FF:FFFF:12:122:124:138  Dallas
2001:1890:FF:FFFF:12:122:120:7    Fort Lauderdale
2001:1890:FF:FFFF:12:122:125:6    Los Angeles
2001:1890:FF:FFFF:12:122:125:44   New York
2001:1890:FF:FFFF:12:122:125:106  Philadelphia
2001:1890:FF:FFFF:12:122:125:132  Phoenix
2001:1890:FF:FFFF:12:122:126:232  San Francisco
2001:1890:FF:FFFF:12:122:125:224  Seattle
2001:1890:FF:FFFF:12:122:126:9    St. Louis
2001:1890:FF:FFFF:12:122:126:64   Washington

*** Please Note:
Ping and traceroute delay figures measured here are unreliable, due to the
high CPU load experienced when complicated show commands are running.

For questions about this route-server, send email to: jayb@att.com

*** Log in with username 'rviews', password 'rviews' *** 

route-server.ip.att.net (ttyp5)

login: rviews
Password:

--- JUNOS 12.1R3-S4 built 2013-03-24 11:22:31 UTC 
rviews@route-server.ip.att.net> show route www.google.com 

inet.0: 462505 destinations, 6937311 routes (462505 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

173.194.78.0/24    *[BGP/170] 3w2d 17:29:34, localpref 100, from 12.122.125.224
                      AS path: 7018 15169 I
                    > to 12.0.1.1 via em0.0
                    [BGP/170] 2w3d 09:11:13, localpref 100, from 12.122.83.238
                      AS path: 7018 15169 I
                    > to 12.0.1.1 via em0.0
                    [BGP/170] 7w5d 19:42:12, localpref 100, from 12.123.1.236
                      AS path: 7018 15169 I
                    > to 12.0.1.1 via em0.0
                    [BGP/170] 7w5d 19:42:22, localpref 100, from 12.123.5.240
                      AS path: 7018 15169 I
                    > to 12.0.1.1 via em0.0
                    [BGP/170] 2w0d 04:42:59, localpref 100, from 12.123.9.241
                      AS path: 7018 15169 I
                    > to 12.0.1.1 via em0.0
                    [BGP/170] 7w5d 19:42:13, localpref 100, from 12.123.13.241
                      AS path: 7018 15169 I
                    > to 12.0.1.1 via em0.0
---(more)---

rviews@route-server.ip.att.net> exit

From the text above, you can actually see my input. You won’t be able to see the passwords but you can see every other command that is typed in by me.

Note: For your previously created sessions, you will have to select it, then click Load, and modify the Logging settings to create a log for those sessions.

Navigating IOS CLI Like a Ninja

August 19, 2013 by Rowell Dionicio 1 Comment

I’m always looking for ways to be more efficient with my work. And when little things like this come my way, I be sure to memorize it and share it.

Here are different keystrokes to help you move around in the Cisco IOS Command Line.

CTRL-A

Moves the cursor to the beginning of the line

CTRL-E

Moves the cursor to the end of the line

Esc B

Moves the cursor back one word.

Esc F

Moves the cursor forward one word.

CTRL-K

Deletes all characters from the cursor to the end of the line.

CTRL-U

Deletes all characters from the cursor to the beginning of the line.

CTRL-W

Deletes the word left of the cursor.

Esc D

Deletes from the cursor to the end of the word.

Esc U

Capatilizes letters from the cursor to the end of the word.

CTRL-L

Redisplay the current command line if you get a message on the screen.

Footer

LET’S TALK

Are you ready to improve your wireless network?

WE'RE LISTENING

© Copyright 2019 Packet6 · All Rights Reserved · Privacy Policy · Terms of Use