Home / Alt manpages / slattach(8)

  • slattach(8)
  • Admin command
  • linux

Attach a Serial Line as a SLIP Interface with slattach

You will finish with a serial device attached as a point-to-point network interface, using slattach from net-tools 2.10. Allow about fifteen minutes for a prepared serial link, plus time to troubleshoot the modem, cable or peer. You need the net-tools package, a serial device, matching settings at the other end and permission to open that device. The examples use /dev/ttyS0 and deliberately use placeholders for the peer's network settings.

Warning

Slattach changes the terminal line discipline. While it is running, the device is being used for network traffic rather than ordinary terminal input. Do not point it at a console, modem or device carrying an active session unless interrupting that session is intended.

1. Confirm the installed command

Check the binary and package before choosing options. These are ordinary read-only commands and do not need elevated privileges:

$ command -v slattach
/usr/sbin/slattach
$ dpkg-query -W -f='${Package} ${Version}\n' net-tools
net-tools 2.10-0.1ubuntu4.4
$ slattach -V
net-tools 2.10
Fred N. van Kempen et al.

The installed program accepts the options in the local help output, including -k for keepalive and -o for outfill. The installed slattach(8) page is older and does not describe those two options, so this guide sticks to options whose behaviour is described by that manpage unless the installed help is explicitly shown.

Checkpoint: verify that the device exists and identify its access group:

$ ls -l /dev/ttyS0
crw-rw---- 1 root dialout ... /dev/ttyS0

The owner, group and device name vary. If your account is not allowed to open the device, resolve that through your normal local access policy. Do not change permissions on a live serial device just to make a test work.

2. Choose the serial device and protocol

Set a shell variable so the device is easy to review before the state-changing command:

$ SERIAL_DEVICE=/dev/ttyS0
$ printf 'serial device: %s\n' "$SERIAL_DEVICE"
serial device: /dev/ttyS0

Without -p, this version selects compressed SLIP, written as cslip in the manpage. Use -p slip for ordinary SLIP, -p adaptive for adaptive CSLIP/SLIP, or -p tty when returning the device to normal serial operation. The manpage also lists ppp and kiss, but they have important boundaries: PPP needs a separate pppd, and KISS links should normally use kissattach.

Both peers must agree on the line speed and protocol. The local default speed is not stated in the manpage, so specify one rather than relying on an undocumented default. Replace 9600 with the value configured at the other end.

3. Attach the line

Elevated privilege is commonly required to open the serial device and configure the network interface. Run the foreground command from a maintenance shell:

$ sudo slattach -v -p slip -s 9600 "$SERIAL_DEVICE"

This command claims and opens the device, switches it into the selected network mode and waits for the line to hang up. The -v option requests verbose messages. Omit it after the setup is understood, or use -d when you need debugging output. Do not use -q while diagnosing a failed link because it suppresses messages.

Leave this process running while the SLIP interface is needed. In a second shell, find the interface and inspect its state:

$ ip link show
$ ps -ef | grep '[s]lattach'

The interface name and link flags depend on the kernel and other SLIP devices already present. Treat slattach still running as evidence that it has not seen a hangup, not as proof that packets can reach the peer.

4. Configure and test the point-to-point addresses

SLIP carries IP packets, but it does not choose the addresses for you. After identifying the new interface, configure the local and peer addresses with your normal network tooling. This is a state-changing, privileged operation. Replace every example value with the addressing plan agreed with the peer:

$ sudo ip address add 192.0.2.1 peer 192.0.2.2 dev sl0
$ sudo ip link set dev sl0 up
$ ip address show dev sl0
$ ping -c 3 192.0.2.2

The documentation example uses sl0 only as a common first interface name. Use the interface that ip link show actually reports. A successful ping demonstrates a working IP path, not merely a serial carrier. If it fails, check the speed, protocol, addresses, cable, peer process and interface name before adding more options.

To undo the address assignment without stopping the serial process, remove the exact address you added:

$ sudo ip address del 192.0.2.1 peer 192.0.2.2 dev sl0

5. Stop cleanly and restore the device

When the link is no longer needed, stop the foreground slattach process with Ctrl-C. If it is managed from another shell, identify the exact process first and send it a normal termination signal. Avoid killing an unrelated process by guessing a PID.

After slattach exits, return the device to ordinary serial operation with the special tty protocol. This requires the same device access and may require elevated privilege:

$ sudo slattach -e -p tty "$SERIAL_DEVICE"

The -e option tells slattach to exit after initialising the device instead of waiting for a hangup. Check that it finished, then confirm that no old slattach process remains:

$ printf 'status: %s\n' "$?"
status: 0
$ ps -ef | grep '[s]lattach' || true

Use -l when your environment requires a UUCP-style lock file in /var/lock. A stale lock can prevent later access, but do not delete one blindly: first establish that no process owns the device. The relevant paths include /var/lock/LCK.*, /dev/ttyS*, /dev/cua* and /dev/ptmx.

Common traps

  • Carrier assumptions: -h exits when carrier is lost and checks carrier status every fifteen seconds. -L enables three-wire operation, sets CLOCAL and disables carrier watching. Choose deliberately; do not add both as a reflex.
  • Unexpected terminal behaviour: -m prevents the usual eight-bit raw initialisation. Leave it out unless the serial protocol requires different line handling.
  • PPP confusion: -p ppp does not replace pppd. It selects a mode that still needs the PPP daemon.
  • Silent failures: -q means quiet mode. Remove it while investigating an open, carrier or protocol problem.

Done means

  • The serial device, speed and protocol match the peer.
  • slattach is running against the intended device, with no console or active session disrupted.
  • The resulting interface has the planned point-to-point addresses and passes a peer test.
  • The foreground process is stopped deliberately when the link is finished.
  • The device is restored with -e -p tty, and no stale process or lock is left behind.