User Tools

Site Tools


Connect a Computer with Raspberry Pi over IP using a USB serial line

Ever wandered you can connect 2 computers over a simple serial line to use the IP protocol?
This is how the whole internet works, basically, but in your small setup :)

In our example, the Raspberry Pi is our router (the one with routing to internet, and any other services), and the other computer is just a slave who wants access to this.

So, the sample code snippets do as follow:

# on the rpi
slattach -p cslip -s 115200 /dev/ttyS0 &
ifconfig sl0 pointtopoint up
# on the pc
ps aux | grep [s]lattach | grep -i ttyusb | awk '{print $2}' | \
    xargs -r --replace=PID kill -9 PID >/dev/null 2>&1
ifconfig sl0 down >/dev/null 2>&1
(slattach -p cslip -s 115200 /dev/ttyUSB* &) >/dev/null 2>&1
sleep 2 && ifconfig sl0 pointtopoint up
ip route del default >/dev/null 2>&1
ip route add default via

Where is the IP of our gateway (in this case the rpi), and is just our serial line client in the other side (the pc)


docu/csheet/net/misc/rpi_pc_serial.txt · Last modified: 2020/05/18 20:51 by admin