Short Answer:
The form of the screen
command I used was:
sudo screen /dev/(serialDevice) (baudRate) (TransmissionRate) (flowControl)
In the case of my MikroTik RB4011 router my successful screen
command looked as follows:
sudo screen /dev/ttyUSB0 115200 cs8 ixoff
Where cs8
is the bit rate of the router and ixoff
for "No Flow Control". The serial connection details- including the 115200 baud rate- for the router were sourced from the manufacturers User Guide PDF.
The name of the device for the serial cable in Linux was derived from the output of udevadm monitor
when I plugged the cable into my Linux host.
Long Answer:
Although this example uses MikroTik router, it should be adaptable to other network devices offering serial port access with slight modifications.
The serial console cable used in the example is found HERE on Amazon and proven to work with both Linux & MikroTik w/out any special drivers being required.
Step 1: Obtain Serial Parameters of Device.
Merely connecting a serial cable between your laptop and the router isn't enough: your laptop needs to communicate with the router using the same settings as it.
In the user guide that ships with the serial device the manufacturer will publish the serial connection parameters. MikroTik tells me that for the RB4011 in this example:
"RJ45 console port for serial console access, set by default to 115200 bit/s, 8 data bits, 1 stop bit, no parity"
This info will be supplied to the screen
command in Step 3.
Step 2: Find the Logical End of Serial Cable in Linux
After making the PHYSICAL connection between your router and laptop with the serial cable we must find the LOGICAL end of the cable as Linux sees it to supply to screen
command as a target.
Execute below command BEFORE inserting serial cable into USB port of your Linux host:
udevadm monitor
Real-time feedback (truncated below for readability) will scroll onto your screen:
KERNEL[19223.032240] add /devices/(SNIP)/1-1.3 (usb)
KERNEL[19223.037774] add /devices/(SNIP)/1-1.3:1.0 (usb)
KERNEL[19223.037937] add /devices/(SNIP)1-1.3:1.0/ttyUSB0 (usb-serial)
KERNEL[19223.041748] add /devices/(SNIP)/1-1.3:1.0/ttyUSB0/tty/ttyUSB0 (tty)
UDEV [19223.063696] add /devices/(SNIP)/1-1.3 (usb)
UDEV [19223.072384] add /devices/(SNIP)/1-1.3:1.0 (usb)
UDEV [19223.078189] add /devices/(SNIP)/1-1.3:1.0/ttyUSB0 (usb-serial)
UDEV [19223.101385] add /devices/(SNIP/1-1.3:1.0/ttyUSB0/tty/ttyUSB0 (tty)
Exit the command with ctrl c
Linux sees our serial cable as: "ttyUSB0". We supply this as a target of screen
in Step 3.
Step 3: Execute screen
Command
Now that we've determined both the connection parameters of our serial device inn Step 1 and identified the logical device of the serial cable in Step 2, we have all the key details required to form and execute the screen
command to (finally) connect to the router.
The form of the command will be:
sudo screen /dev/(device name from udevadm) (baudRate) (TransmissionRate) (flowControl)
Using the manufacturer's settings for the serial connection we'll specify the "8 bits" as cs8
and since MikroTik does NOT use Flow Control we'll set this as ixoff
. Our command will now look as follows:
sudo screen /dev/ttyUSB0 115200 cs8 ixoff
Please note that the above command is known to work with the MikroTik RB4011, but you might need to tweak it for your specific device. man screen
to review alternative settings to those in my example.
In lieu of using screen
, you could use minicom -s
, but I feel screen
is more straight forward as you can just append the connection parameters and not go through a separate setup menu.