3

My objective is to use pppd over socat. I have two Ubuntu boxes with eth0 connected (physically) to each other. I can ping both the IP addresses. I do the below on each Ubuntu box.

  1. Create a pseudo serial device and link it to my network interface "eth0".
    socat PTY,link=/dev/ttyp10 INTERFACE:eth0
  2. Use pppd on this pseudo serial device.
    Device A:
    pppd noauth /dev/ttyp10 10.10.10.10:20.20.20.20
    Device B:
    pppd noauth /dev/ttyp10 20.20.20.20:10.10.10.10

I see that my ppp0 interface gets created for a short time but I cannot ping both the IP addresses (10.10.10.10 or 20.20.20.20). I know my solution is not complete as I need to specify how my pppd packets must be routed from my eth0 interface but not sure how to do it (I used tcpdump on eth0 interface and found some data).

I tried the same experiment by binding socat to a TCP server/client and it worked.

Device A:
1. socat pty,link=/dev/ttyp10,raw,echo=0 TCP4-LISTEN:7001,reuseaddr &
2. pppd noauth /dev/ttyp10 10.10.10.10:20.20.20.20

Device B:
1. socat pty,link=/dev/ttyp10,raw,echo=0,waitslave TCP4:20.1.1.2:7001 &
2. pppd noauth /dev/ttyp10 20.20.20.20:10.10.10.10

Note: 20.1.1.2 is the "eth0" IP address of Device A. With this my ppp0 interface is up and I can ping both IP addresses (10.10.10.10 and 20.20.20.20).

Why I need to use the pseudo serial device when I have a working eth0 interface is a different question and lets not discuss that.

Neo
  • 141
  • 5
  • 16
  • What's the protocol stack you're trying to achieve? – ysdx Mar 14 '16 at 22:29
  • @ysdx I want to send IP over PPP but since PPP needs a serial port, I was using SOCAT to bridge this gap. Hope i have answered your question. – Neo Mar 14 '16 at 22:44

1 Answers1

3

You probably want to adapt this example taken from the socat man page:

socat PTY,link=/var/run/ppp,rawer INTERFACE:hdlc0

circumvents the problem that pppd requires a serial device and thus might not be able to work on a synchronous line that is represented by a network device. socat creates a PTY to make pppd happy, binds to the network interface hdlc0, and can transfer data between both devices. Use pppd on device /var/run/ppp then.

In this example, the interface is an synchronous line (seen by the OS as a HDLC interface). pppd uses (by default) a HLDC-like framing so it makes sense to pipe the raw data from pppd to the HDLC device.

In your case, you are using an Ethernet device and this does not make much sense to do the same thing.

In your second example, you managed to transport your PPP session over TCP which is a quite simple and viable option. Another solution in your case would be to use PPPoE which is designed for transporting PPP over Ethernet.

Community
  • 1
  • 1
ysdx
  • 8,889
  • 1
  • 38
  • 51
  • Agreed, I wanted to process the raw pppd packets. I still used SOCAT to pipe in data from a pseudo terminal and route it to a TCP socket. I wrote an application to connect to this TCP socket (created by SOCAT) and process the raw pppd packets. – Neo Mar 17 '16 at 18:14
  • 1
    I've found that `pppd` sometimes gives "Access denied" when trying to use a symlink created by `socat`. Solution was to use `"$(realpath /tmp/uart)"` (or presumably, `readlink` would work too) in place of `"/tmp/uart"` in `pppd`'s argument list, so it gets the direct path to the virtual device rather than a symlink to it. – Mark K Cowan Jun 11 '18 at 09:41