Linux – Connecting to an analog dial-in PSTN terminal without a PSTN line

dialuplinuxmodempstnterminal

there's a computer ("server") that has no Internet connection, and it is located in a place with no GSM signal. The only way to get connection to it is an analog modem (US Robotics 56Kbit/s). This modem is connected to a national PSTN line with a geographical number, and the server (running a modern Linux distribution) is configured to offer a dial-in serial terminal. To clarify, when you phone to this PSTN line, the modem handshakes (I think it's the V90 protocol), then you're presented with the login and then you are in on ttyS0. There's no IP/PPP protocol stack, just the serial terminal.

I would like to connect to this server in any way that does not require me to carry around a physical analog modem and (what's worse) finding around a physical PSTN line which is really a scarce resource at least in business context here in Italy. To clarify: the PSTN line on the server side is the only way through, but I would like to be able to connect to it without a physical PSTN line on the client side.

Some ideas that came through my mind but I do not know if they can be really implemented or not:

  • Having a mobile phone connected through bluetooth/USB. Old phones exported a ttyUSB that handled AT commands, but then there was no way (AFAICT) to get the audio stream. I don't know if it's technically possible to write an Android app that makes a phone call, then encodes the audio into a semi-raw UDP stream.

  • Routing the call through VOIP. Googling around, some people seems to have had mixed success with doing analog modem calls through a VOIP termination with g711 (uLaw/aLaw). It looks like it is possible to get at least 9600bps, which is enough for me.

  • Even if one of the above is possible, is there any software available that emulates the full V90 protocol/handshake/whatever and en/decodes audio into bytes?

  • Is there any online service that offers a battery of analog modems to subscribers? Doesn't sound a business I would personally invest on, but you never know 🙂

  • Is there any physical object that is the modern UMTS equivalent of an analog modem, like a box connected through USB where you put the SIM inside, it does all the magic, and gives you a ttyUSB on your PC?

  • Assuming that I can physically access the server just once, is there anything I can install (either hardware or software) on the server and that would make my life easier? The only requisite is that must go through a standard national PSTN line (dual twisted copper), there's no other way to get any other signal. The modem looked like the best option, at first, but you never know.

Thanks!

Best Answer

I suspect there are lots of ways to do this. One that comes to mind is callback.

You register a dialin ISP account for the modem on the server; that's simple enough, and non-contentious. You will need an ISP that will allocate you a static address; if this costs extra, pay it.

You then configure something like diald to bring the link up and down on demand. Then write a little script, perhaps using swatch, to detect "RING" messages appearing in the modem logfiles, and when it sees them, to generate traffic that diald considers "interesting" - ie, traffic that causes it to bring up the line.

When you want to connect to the server over the regular internet, you call the phone line attached to the server, from any landline or GSM phone. The script on the server detects the phone RINGing, and generates interesting traffic for diald. Diald brings up the PPP connection, at which point the server is available on the known, static IP address.

You, using regular internet tools, connect in via SSH (or any other IP protocol or combination thereof which pleases you), until you're done. When you're done, you drop all these connections, and after a short while diald realises the line is idle and hangs up the modem.

Rinse. Repeat.

Possible enhancements: if you can't get an ISP service that does static addresses, you could configure diald so that the first thing that happens after the internet link comes up is that it emails it's current IP address to a pre-arranged address, or in some other way communicates it to the internet. That way you can find out what dynamic address it's got each time the line comes up, so you can talk to it. But a static address would be easier.

Alternative suggestion: consider that most GSM phones will happily make a PPP connection to any old POTS number, to establish the terminal session. I wrote this technote some years ago on the nuts and bolts of getting a GSM phone with a modem that honoured the AT command set (which is most of them) to dial in to an ISP.

It's completely legal to have the GSM phone dial a standard landline instead of the magic "bring up GPRS" number, just replace

atd*99***1#

with

atd0039nnnnnnnn

in /etc/ppp/chat-gprs, where nnnnnnnn is your server's landline number. Note this will only work with GPRS, and maybe EDGE. 3G is a whole different protocol accessed in different ways, so you'll only get a slow (20kb/s or so) connection this way. But for a straight terminal session, that may be enough.