OpenBSD Journal

Using Remote Modem

Contributed by sean on from the AT&F1 ATDT8675309 dept.

Alexey Vatchenko writes in:
Sometimes we need to use a modem or some other serial device connected to another computer. And occasionally, we have access to the device itself. So, here is an example of how it can be accomplished.

To do this we need my netfwd utility (http://www.bsdua.org/netfwd.html). Using netfwd we can easily use a modem connected to another BSD computer.

Suppose that we have two computers, one with physical modem and another computer needs to use it.

Computer with modem

In this example I use a Nokia 6230i phone for connecting to the Internet. I use DKU-2 cable to connect the phone to the computer's USB port. The /dev/cuaU0 device node will be created as soon as I connect phone to the computer. Now, use netfwd to accept incoming connections on port 5555 and redirect all traffic to serial device /dev/cuaU0.

# netfwd -d -v tcp 5555 tty /dev/cuaU0 115200,8,N,1,H

Another computer

On this computer, I use ppp(8) to connect to the Internet. Pay attention to the device parameter in the following configuration file (some parameters are specific to my phone and mobile operator, MTS in this example).

mobile:
 set device remote_computer:5555/tcp
 set dial "ABORT ERROR ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
           \"\" ATZ OK-ATZ-OK AT+CGDCONT=1,\\\"IP\\\",\\\"hyper.net\\\" \
           OK \\dATD\\T TIMEOUT 40 CONNECT"
 set phone "*99#"
 set speed 115200
 set login
 set timeout 0
 set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
 add default HISADDR
 enable dns

Now, type the following in shell...

# ppp -ddial mobile

and you will get your Internet connection. It's simple as UNIX should be :)

NOTE: Alexey's utility is not in the ports tree as of yet so if you have the knowledge and a few moments to spare why not submit it as a new port?

(Comments are closed)


Comments
  1. By corey (208.191.177.19) on

    socat is in ports. I've never used it to forward to a modem on a remote machine, but I've used it to bridge an application that only knew TCP sockets to a serial port. Worked great.

    That's not to say Alexey's utility shouldn't be ported, though. Choice is good.

    Comments
    1. By Alexey Vatchenko (av) av@bsdua.org on http://www.bsdua.org

      > socat is in ports. I've never used it to forward to a modem on a remote machine, but I've used it to bridge an application that only knew TCP sockets to a serial port. Worked great.

      I didn't know about socat.
      Anyway, my goal is to create BSD specific (kqueue/kevent), BSD licensed, no forking, easy-to-use program with a clear code and clear design. It doesn't mean that socat is opposite :)

      I'm going to create ``port''. I never did this before, so i need some time :) Anyway, if someone wants to help, it would be cool!

  2. By Sacha Ligthert (213.46.69.133) sacha@ligthert.net on

    So far for capthca...

    Comments
    1. By Daniel Hartmeier (dhartmei) on janitor

      > So far for capthca...

      They did read and type in the captcha...

  3. By Peter (65.43.81.8) on pbw.us

    When I used PPP for my connection to the internet, I had it on demand dial so it would reconnect if it lost the connection. Upon connecting I had ifconfig run and e-mail me the new ip address (using ppp.linkup) so that I could still ssh into the computer even though it had a dynamic ip...it was really useful!

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]