Running PPP over Docker Ubuntu 20.04: Connecting Physical Modem via Socat
This article focuses on the process of running PPP (Point-to-Point Protocol) over Docker in Ubuntu 20.04, specifically for testing dial-up connections. We will cover the steps required to connect a physical modem via a Socat loop.
Prerequisites
Before we begin, make sure you have the following:
- A physical modem
- Ubuntu 20.04 installed
- Docker installed
Step 1: Create a Docker Image
First, we need to create a Docker image based on Ubuntu 20.04. We will use the following Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y ppp socat
CMD ["bash"]To build the image, run the following command:
$ docker build -t ppp-docker .Step 2: Run the Docker Container
Next, we need to run the Docker container and connect the physical modem via a Socat loop. Use the following command:
$ docker run -it --rm --name ppp-container ppp-docker /bin/bash -c "socat /dev/ttyUSB0,raw,echo=0,crnl pppd nodetach noauth debug dump logfile /dev/stdout"`Replace /dev/ttyUSB0 with the correct device path for your physical modem.
Step 3: Configure PPP
Once the container is running, we need to configure PPP. This can be done by editing the /etc/ppp/peers/dialup file inside the container. Here is an example configuration:
/etc/ppp/peers/dialup:
460800
crtscts
modem
lock
connect '/usr/sbin/chat -v -f /etc/ppp/chatscripts/dialup'
disconnect '/usr/sbin/chat -v -f /etc/ppp/chatscripts/disconnect'
debug
noipdefault
defaultroute
usepeerdns
Step 4: Test the Connection
Finally, we can test the connection by running the following command inside the container:
$ pppd call dialupIf everything is configured correctly, you should see output similar to the following:
Serial connection established.
Using interface ppp0
Connect: ppp0 <--> /dev/pts/0
sent [LCP ConfReq id=0x1 ]
rcvd [LCP ConfReq id=0x1 ]
sent [LCP ConfAck id=0x1 ]
rcvd [LCP ConfAck id=0x1 ]
sent [LCP EchoReq id=0x0 magic=0x16a3a7e9]
rcvd [LCP EchoRep id=0x0 magic=0x16a3a7e9]
sent [CCP ConfReq id=0x1 ]
rcvd [CCP ConfReq id=0x1 ]
sent [CCP ConfAck id=0x1 ]
rcvd [CCP ConfAck id=0x1 ]
sent [IPCP ConfReq id=0x1 ]
rcvd [IPCP ConfReq id=0x1 ]
sent [IPCP ConfAck id=0x1 ]
rcvd [IPCP ConfAck id=0x1 ]
Script /etc/ppp/ip-up started (pid 30)
Script /etc/ppp/ip-up finished (pid 30), status = 0x0
Local IP address changed to 10.0.0.1
In this article, we have covered the process of running PPP over Docker in Ubuntu 20.04, specifically for testing dial-up connections. We have also covered the steps required to connect a physical modem via a Socat loop and configure PPP.