pppd Command in Linux
The pppd daemon in Linux is a Point-to-Point Protocol (PPP) daemon that establishes internet links over dial-up modems, DSL connections, and many other point-to-point links using the PPP protocol.
The pppd daemon works with the kernel PPP driver to set up and manage a PPP connection. It assigns IP addresses, handles authentication, and supports other network protocols, though IP is the most common.
Table of Contents
Here is a comprehensive guide to the options available with the pppd command −
Syntax of pppd Command
The syntax of the pppd command in Linux is as follows −
pppd [options]
In the above syntax, the [options] field is used to specify options, such as the serial port, speed, and others.
pppd Command Options
The common options of the pppd command are listed below −
Option | Description |
---|---|
ttyname | Uses the specified serial port. If no / is given, /dev/ is prefixed. Defaults to the terminal if not set. |
speed | Sets the baud rate for the serial device. Some systems allow any value, while others support only standard rates. |
asyncmap map | Defines control characters to escape in PPP packets. Given as a hexadecimal bitmask. Defaults to none. |
auth | Requires the peer to authenticate before sending/receiving packets. Enabled by default if a default route exists. |
call name | Loads additional options from /etc/ppp/peers/name. It may include privileged options. |
connect script | Runs a script before starting PPP, usually for dialing a modem. Often uses chat. |
crtscts | Enables hardware flow control (RTS/CTS). If not set, the existing serial port setting is used. |
defaultroute | Adds a default route using the peer as a gateway. Removed when the connection is lost. |
disconnect script | Runs a script after the link is closed (to hang up a modem). |
escape xx,yy,... | Escapes specified characters in transmission. Accepts a list of hex values. |
file name | Reads options from the specified file. |
init script | Runs a script to initialize the serial line, generally for modem setup. |
lock | Creates a lock file to prevent multiple processes from accessing the serial device. |
mru n | Sets the Maximum Receive Unit (MRU) size (default: 1500 bytes, min: 128, max: 16384). |
mtu n | Sets the Maximum Transmit Unit (MTU) size. Defaults to 1500, but must be at least 1280 for IPv6. |
passive | Waits for a response after initiating a connection instead of exiting immediately. |
Examples of pppd Command in Linux
This section explains how to use the pppd command in Linux with examples −
- Connecting to a Serial Device
- Connecting to a Serial Device Without Authentication
- Connecting to a Serial Device with Flow Control
- Connecting to a Serial Device Using Chat Script
- Preventing Multiple Processes from Accessing the Serial Device
- Setting Maximum Receive Unit (MRU)
- Setting Maximum Transmit Unit (MTU)
- Displaying pppd Version
- Displaying Usage Help
Connecting to a Serial Device
To connect to a serial device, use the pppd command in the following way −
sudo pppd /dev/ttyS0 115200
In the above command, /dev/ttyS0 is the serial device, and 115200 is the baud rate.
Connecting to a Serial Device Without Authentication
To connect to a serial device without authentication, use the noauth option −
sudo pppd /dev/ttyS0 115200 noauth
Use noauth only for testing purposes.
Connecting to a Serial Device with Flow Control
Flow control is a mechanism that manages the data transmission rate between two devices to prevent data loss. To connect to a serial device with flow control, use the crtscts option. This option uses RTS (Request to Send) and CTS (Clear to Send) signals in RS-232 communication −
sudo pppd /dev/ttyS0 115200 crtscts
Connecting to a Serial Device Using Chat Script
A chat script is a text file used by the chat program to automate the process of establishing a PPP connection. It sends a series of AT commands to the modem and waits for specific responses. To dial the modem using a chat script, use the connect option −
sudo pppd connect "chat -f /etc/ppp/chat-script" /dev/ttyS0 9600
Preventing Multiple Processes from Accessing the Serial Device
To prevent multiple processes from accessing the serial device, use the lock option. It ensures that only one process can use /dev/ttyS0 at a time −
sudo pppd /dev/ttyS0 115200 lock
Setting Maximum Receive Unit (MRU)
To set the maximum receive unit (MRU), use the mru option with the number of bytes. For example, to set the MRU to 1400 bytes, use the following command −
sudo pppd /dev/ttyS0 115200 mru 1400
Setting Maximum Transmit Unit (MTU)
To set the maximum transmit unit (MTU), use the mtu option with the number of bytes. For example, to set the MTU to 1400 bytes, use the following command −
sudo pppd /dev/ttyS0 115200 mtu 1400
Displaying pppd Version
To display the pppd version, use the --version option −
pppd --version

Displaying Usage Help
To display the pppd command usage help, use the -h or --help option −
pppd --help

Conclusion
The pppd daemon in Linux establishes and manages Point-to-Point Protocol (PPP) connections, enabling communication over serial links like dial-up modems and DSL. It provides options for authentication, flow control, and network configuration, allowing customization based on connection requirements.