Serial communication from Ubuntu 22.04 to Cisco 1812J

Cisco
日本語 / 한국어

To configure the Cisco 1812J, you must log into the console from an external terminal.
In most cases, a Windows OS is used for it, but this time I will use an Ubuntu OS.
In this article, I will connect to a Cisco 1812J from Ubuntu using serial communication.
After this step, you will be able to operate your Cisco 1812J from Ubuntu.

Equipment

  • Ubuntu 22.04 (Fujitsu LIFEBOOK S560/B)
  • Cisco 1812J
  • USB to RJ45 Console Cable

Architecture

Prerequisites

This article assumes you already have the following:

  • The laptop already has Ubuntu installed.
  • The console cable has connected between the laptop and Cisco 1812J.

How to

Open “Terminal” in Ubuntu and check the USB port used by console cable with the following command.
In the example below, the console cable uses ttyUSB0.

user@ubuntu:~$ sudo dmesg | grep ttyUSB
[   34.739950] usb 1-1.3.4: FTDI USB Serial Device converter now attached to ttyUSB0
[   34.996889] usb 1-1.3.1: pl2303 converter now attached to ttyUSB1

Try connecting with the settings in following Cisco’s Start Guide.

9600 baud
8 data bits
No parity bits
1 stop bit

Cisco 1811 and 1812 Integrated Services Router Cabling and Installation
user@ubuntu:~$ sudo cu --speed 9600 --parity=none --line /dev/ttyUSB0
cu: open (/dev/ttyUSB0): Permission denied
cu: /dev/ttyUSB0: Line in use

Even though I run cu command with sudo, you can get permission denied error.
According to the specifications of the cu command, it is executed as a general user.
And then, you should add permissions before you try.

user@ubuntu:~$ ls -l /dev | grep USB
crw-rw----  1 root dialout 188,   0  3月 26 14:46 ttyUSB0
crw-rw----  1 root dialout 188,   1  3月 26 14:46 ttyUSB1

user@ubuntu:~$ sudo chmod 666 /dev/ttyUSB0

user@ubuntu:~$ ls -l /dev | grep USB
crw-rw-rw-  1 root dialout 188,   0  3月 26 14:46 ttyUSB0
crw-rw----  1 root dialout 188,   1  3月 26 14:46 ttyUSB1

user@ubuntu:~$ cu -s 9600 -l /dev/ttyUSB0
Connected.

Router1>

The connection is now complete!

You can exit from serial communication by typing “~.”

Router1>~.
Disconnected.
user@ubuntu:~$

Notice

If serial communication was not terminated normally last time, reconnection may fail as shown below.

user@ubuntu:~$ cu --speed 9600 --parity=none --line /dev/ttyUSB0
cu: /dev/ttyUSB0: Line in use

In this case, you can unplug the console cable from the USB port and reconnect it.
Alternatively, you run the following commands for reconnecting the console cable to the USB port.

Check device number from USB port (ttyUSB0).
In the example below, the device number is 1-1.3.1.

user@ubuntu:~$ sudo udevadm info --query=path --name=/dev/ttyUSB0
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3.1/1-1.3.1:1.0/ttyUSB0/tty/ttyUSB0

Disconnect by specifying the device number.

user@ubuntu:~$ sudo echo -n "1-1.3.1" | sudo tee /sys/bus/usb/drivers/usb/unbind
1-1.3.1

The device is no longer recognized as you can see in the command below.

user@ubuntu:~$ sudo udevadm info --query=path --name=/dev/ttyUSB0
Unknown device "/dev/ttyUSB0": No such file or directory

Reconnect your device.

user@ubuntu:~$ sudo echo -n "1-1.3.1" | sudo tee /sys/bus/usb/drivers/usb/bind
1-1.3.1

Start connecting again by adding permissions.

user@ubuntu:~$ cu --speed 9600 --parity=none --line /dev/ttyUSB0
cu: open (/dev/ttyUSB0): Permission denied
cu: /dev/ttyUSB0: Line in use

Comments

タイトルとURLをコピーしました