Ubuntu Serial Port Sniffer Linux



Content Cleanup Required
This article should be cleaned-up to follow the content standards in the Wiki Guide. More info...

  1. Ubuntu Serial Port Sniffer Linux File
  2. Ubuntu Serial Port Tool

This document presents (almost) the minimum amount of work required to enable a serial console login on an Ubuntu 6.06 and later versions. (Minor changes have been added to improve performance.) Both server and client settings are included.

Ubuntu Serial Port Sniffer Linux

This procedure was developed using the Remote Serial Console HOWTO (see 'External links' below), and adapted to apply specifically to Ubuntu. The reader is referred to this document for any issues arising from using this HOWTO.

Assumptions

  • You have enabled the serial console in your BIOS.1

  • The serial connection is being made at 115200 baud 8n1, on first serial port, called /dev/ttyS0 in linux (9600 8n1 is the default fall back if your hardware does not support 115200 baud)
  • You are comfortable editing critical system files such as /etc/inittab, /boot/grub/menu.lst
  • You are using a serial (null modem) cable. It is also possible to use a USB to Serial adaptor, but the tty* must be changed to reflect your hardware.
  • You have an available serial console on ttyS0. If your not getting any output, a real serial port or other device might be using ttyS0. Try using ttyS1, ttyS2, etc.

If you want to use a standard Ethernet/RJ-45 cable for serial connection you can buy a couple of Serial to Cat 5 adapters or make one yourself.

Server Setup

DESCRIPTION Nast is a packet sniffer and a LAN analyzer based on Libnet and Libpcap. It dumps the headers of packets and the payload in ascii or ascii-hex format. You can apply a filter. I figured I'd give a rundown of serial terminals I regularly use on Linux to access consoles on embedded boards through a serial port. I tend to favor both Putty (runs on Windows and Linux) and screen, but a couple others are listed here as well. This is a GUI that's pretty feature rich. It can also be used for SSH and telnet.

Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. I know for a fact that the port (console on a switch) is 9600 8/n/1, so it should be simple. TtyUSB0 shows up in dmesg. So shouldn't I be able to select /dev/ttyUSB0 in putty's serial configuration and it should work. Works fine when I'm running putty with windows. Doesn't work with Ubuntu/putty. I get no response. This is how I started it.

Configuring the console login process

This section details how to configure the 'getty' process to enable a login via the console port. You need to configure either an Upstart system or the older inittab, depending on Ubuntu version you are using.

Configuring upstart (Karmic and newer)

1) Create a file called /etc/init/ttyS0.conf containing the following:

2) Ask upstart to start the getty

Configuring upstart (Edgy/Feisty/Jaunty)

Create a file called /etc/event.d/ttyS0 containing the following:

Configuring inittab (only Dapper and older !)

1) Edit /etc/inittab

2) Change the following line:

to:

3) Restart init:

At this point, a new login prompt should appear on the output of the serial console.

Configuring grub

This section details how to get grub talking via the serial port.

This section is optional if the user does not want grub interaction via the serial console port.

Configuring (Karmic and newer)

1) Edit /etc/default/grub

2) update grub

update-grub

Configuring grub (Edgy/Feisty/Jaunty)

1) Edit /boot/grub/menu.lst:

2) Add the following lines to the top of the file:

3) When you next reboot, the output from grub will go to the normal console unless input is received from the serial port. Whichever receives input first becomes the default console. This gives you the best of both worlds.

Configuring the kernel boot parameters

This section details how to configure the kernel boot parameters to get boot information through the console port.

This section is optional if the user does not want the kernel boot messages to appear on the serial console port.

The following procedure can be carried out by modifying the 'kernel' line in grub prior to committing the changes directly to the /boot/grub/menu.lst file.

1) Edit /boot/grub/menu.lst:

2) Modify the kernel line for the image you want to boot using the serial console on. In this case, I'm setting up the default 2.6.10-5.386 kernel to use the serial console line. Change:

to:

Note two 'console=' kernel options. You can specify this option several times. All devices, mentioned in it will receive kernel messages (those, generated by printk() and seen by dmesg). However, stdin/stdout/stderr of /sbin/init process will be set to the last device only, therefore only the last device will show startup messages and act as a console in single-user mode.

3) Reboot into this kernel. Output from the boot process should be sent via the serial console line.

Client Setup

1) Ensure you have a read/write permissions on /dev/ttyS0.

if the last command didn't show an output add yourself to dialout group and logout/login:

Alternatively, you can always run minicom through sudo, but it's not recommended.

2) Install minicom

3) Configure minicom.

4) Configure client serial port settings: In Serial port setup, set the following options

4b) Using 7.10 on the server, I needed to set the following on the client:

My 7.10 client and Windows' HyperTerminal both defaulted to Yes; until I changed this client -> server communication did not work.

5) Configure Initialization string: In Modem and dialing clear the init

6) Save setup as dfl

7) You might need to press enter several times to get the connection running.

8) To log on in the future, run

and press enter several times if it does not come up on start up.

Alternative serial client: screen

GNU screen actually makes quite a capable serial terminal.

To install:

To start:

(adjust to requirements)

To end the session, use Ctrl-A,Shift-K.

External links

  • Serial Console Howto

  • Serial Console

  1. This is only needed if you plan to use serial console to enter BIOS configuration utility or observe early startup messages even before GRUB starts. Note, that in some cases it may interfere with GRUB settings described below. If you're sure you've configured GRUB correctly, but the serial menu does not appear, try disabling serial console support in BIOS. (1)

Linux

Translation(s): English - Italiano - Русский

?Discussion

How to identify a device > serial device

How to 'identify' the serial device (/dev/ttyS*) for a given interface of your computer (not the peripheral connected behind it).

The serial interfaces (RS-232) is a legacy interface. It has no enumeration process, you have to tell your application which /dev/ttyS* to use (some application do have some auto-detection features, but it's not always reliable).

The Serial port can either have a physical interface on your computer:

  • DB9 serial interface.
  • DB25 serial interface (on older computers).
  • RJ-45 serial interface (mostly on switch and routers, but also on some computers like Sun ones).

Or it can be 'built-in' another device, like:

Ubuntu Serial Port Sniffer Linux File

  • Internal Modem (ISA, PCI...).
  • PC Card (pcmcia, Cardbus...), including Modem, GSM or UMTS/3G cards.
  • USB to serial adapters.
  • Docking station (for laptop).

Often, the computer have an internal UART chipset, but not a physical interface : Recent laptops have the DB-9 connector on the docking station only ; Some desktop have 1 connector available, the 2nd requires an optional cable, etc. so what you see IS NOT what you have.

Using hal

hal in installed by default in Desktop Environment (both Gnome and Kde), but not on servers.

Take special attention to 'info.product' and 'linux.device_file' lines :

more example : thinkpad-a22-hal.txt ; usb-to-serial-adapter_hal.txt

Find in /sys/*

This command should work on all standard Debian installation (even minimalist ones).

Ubuntu Serial Port Tool

Ubuntu Serial Port Sniffer Linux

some explanations on this example :

serial8250
ttyS* under 'serial8250' probably doesn't exist (they are present by default because it's hard to detect if they are present or not)
0000:00:1e.0/0000:15:00.0/0.0/tty:ttyS1

if you look at the lspci output above, pci device '00:1e.0' is a PCI bridge to the card bus controller ('15:00.0'), so ttyS1 is a PC Card device.

pci0000:00/0000:00:03.3/tty:ttyS0
ttyS0 is directly connected to the PCI bus. according to the PCI device name, you can assume it isn't a Modem, so it's probably a built-in serial interface.
ttyUSB0/tty:ttyUSB0

if you look at the lspci output above, pci device '00:1a.0' is a USB Controller, so ttyUSB1 is a USB device (USB-to-serial or modem).

more example : thinkpad-a22-find-sysfs.txt

keywords:UART ; 8250 , 16550 ; 16450 ; RS232 ; RS-232 ; DB-9 ; DB9 ; DB25 ; UART ; Serial ; ttyS0 ; ttyS1 ; ttyS3 ; ttyS4 ;COM1 ; COM2 ; Com Port





Comments are closed.