Difference between revisions of "Dial-up pool"

From Doge Microsystems
Jump to navigation Jump to search
(first pass of edits)
Line 1: Line 1:
 +
[[File:Dial_pool_header.jpg|right|550px|frameless|]]
 +
 +
<!-- The hook: *why* should people want to read/do this? You can't start out presuming people want to read this article at all. -->
 +
 +
Dial-up internet connections may feel like a relic of the past, but modern telephony equipment makes it cheap & easy to set up your own dial-up ISP!
  
Setting up your own Dial-up ISP with the ability to serve multiple clients is fairly straight forward but requires certain hardware, favorable network conditions, and a bit of patience.
+
Forget about pricey interconnects with the phone company: with a few pieces of commodity hardware and an hour of setup, you can emulate a blazing fast 56&nbsp;kbps network connection between two or more clients.
  
This guide is intended to be as complete as possible and uses a Raspberry Pi computer for ease of use, but any computer with enough serial or USB ports that can run a modern Linux distribution will work.
+
<!-- You should fill this with other copy to push the tables below the header image. Why did you undertake this project? What are people going to get out of it? -->
  
[[File:Dial_pool_header.jpg|right|550px|frameless|]]
+
== Requirements ==
== Prerequisites ==
 
  
==== Hardware Requirements ====
+
=== Hardware Requirements ===
* One or more hardware modems (no software modems or "winmodems")
 
* A Linux device (e.g. x86 computer, Raspberry Pi, etc.) to communicate with the modem(s) as the dial-in server
 
* A client device with a modem (any type, hardware or software)
 
* Some form of telephony connection between clients' modems and the ISP modems. I'll be using a software PBX and VoIP analog telephone adapters (ATAs)
 
<br />
 
The hardware used in this guide:
 
  
* Raspberry Pi 3B
+
{| class="wikitable"
* Modems:
+
|+ Hardware Requirements
** Matrix MX 14.4k Modem using XECOM XE1414 module (V.32) ([https://dogemicrosystems.ca/files/dial/XECOM_XE1414.pdf Datasheet])
+
!
** USRobotics Sportster 0459 56k External Modem (only 28.8 up) ([https://dogemicrosystems.ca/pub/USRobotics/sportster/sportx2_Sportster_56K_x2.pdf Manual])
+
! Suggested hardware
** Practical Peripherals PM144MT II Modem (V.32)
+
! Used in this guide
** USRobotics USR5637 USB 56k Modem (V.92) ([https://dogemicrosystems.ca/pub/USRobotics/USR5637/5637-ds.pdf Datasheet])
+
|-
* 3x USB to RS-232 serial adapters, ch341 chipset
+
! Dial-in server
 +
| Any computer that supports a Unix/Linux operating system || Raspberry Pi 3 model B
 +
|-
 +
! Server modem(s)
 +
| Any hardware modem(s) (see the ''Choosing Modem Hardware'' section below) ||
 +
* Matrix MX 14.4k Modem using XECOM XE1414 module (V.32) ([https://dogemicrosystems.ca/files/dial/XECOM_XE1414.pdf datasheet])
 +
* USRobotics Sportster 0459 56k External Modem (only 28.8 up) ([https://dogemicrosystems.ca/pub/USRobotics/sportster/sportx2_Sportster_56K_x2.pdf manual])
 +
* Practical Peripherals PM144MT II Modem (V.32)
 +
* USRobotics USR5637 USB 56k Modem (V.92) ([https://dogemicrosystems.ca/pub/USRobotics/USR5637/5637-ds.pdf datasheet])
 +
|-
 +
! Client device(s)
 +
| Any computer with a dial-up modem || Custom Windows 95 computer with a USRobotics Sportster 33.6k ISA modem
 +
|-
 +
! Telephony
 +
| Any device that can emulate a telephone line || 4x Linksys SPA-2102 analog telephone adapters (ATA) (don't stack these &mdash; they get hot!)
 +
|-
 +
! Connectors and adapters
 +
| Whatever you need to connect the server modems to the dial-in server ||
 +
* 3x USB to RS-232 serial adapters (CH341 chipset)
 
* 3x DE-9 to DB-25 serial adapters
 
* 3x DE-9 to DB-25 serial adapters
* 4x Linksys SPA-2102 analog telephone adapter (ATA) (Note: these can reach 50+°C! Don't stack them!)
+
|}
<br />
+
<br />
+
 
 +
{| class="wikitable"
 +
|+ Software Requirements
 +
!
 +
! Suggested software
 +
! Used in this guide
 +
|-
 +
! Dial-in server
 +
| Any Linux/Unix operating system || Debian Buster (Raspbian Lite release)
 +
|-
 +
! Telephony
 +
| Real PSTN telephone lines, custom dial tone circuitry, or a software PBX || Asterisk v16.2.1
 +
|-
 +
! Tunnelling daemon
 +
| Any ppp daemon || Samba ppp v2.4.7
 +
|-
 +
! Terminal manager
 +
| Any terminal multiplexer with virtual terminal support || mgetty v1.2.1
 +
|}
 +
 
 +
=== Choosing Modem Hardware ===
 +
 
 +
Despite variations in modem hardware, this guide should work with any dial-up modem that presents itself as a serial device to the operating system, whether it connects over USB, ISA, PCI, or RS-232.
 +
 
 +
However, '''you should avoid using [https://en.wikipedia.org/wiki/Softmodem software modems]''' (sometimes called "softmodems" or "Winmodems") because they are error-prone and difficult to debug. This guide uses three external serial modems (with USB to RS-232 adapters) and one USB modem. Dedicated serial hardware is easy to troubleshoot, and scales to as many lines as you have USB ports.
 +
 
 
<gallery mode="traditional">
 
<gallery mode="traditional">
 
Four_modems.jpg|Three external RS-232 and one USB modem
 
Four_modems.jpg|Three external RS-232 and one USB modem
Line 31: Line 72:
 
Modem_USB_serial.jpg|Modem and USB to DE-9 adapter
 
Modem_USB_serial.jpg|Modem and USB to DE-9 adapter
 
Pi_USB_and_modems.jpg|Raspberry Pi, modems, and USB adapters
 
Pi_USB_and_modems.jpg|Raspberry Pi, modems, and USB adapters
Four_SPA-2102.jpg|Four SPA-2102
+
Four_SPA-2102.jpg|Four SPA-2102 ATAs
Raspberry_pi_3_in_case.jpg|Raspberry Pi 3b in a case
+
Raspberry_pi_3_in_case.jpg|Raspberry Pi 3 model B in a case
 
</gallery>
 
</gallery>
 
==== Software Requirements ====
 
* Raspbian, Debian, Ubuntu, or any modern Debian based Linux distribution (other flavors will work but the configuration will be different)
 
* ppp
 
* getty
 
* Asterisk
 
 
== Choosing Modem Hardware ==
 
Modem hardware varies greatly, but this project doesn't require anything beyond standard protocols between your ISP and client modems (V.32, V.34, etc.).<br />
 
This guide ''should'' work with any dial-up modem that presents itself as a serial device to the operating system, including cheap USB modems, ISA modems, PCI modems and of course external RS-232 serial modems.<br /><br />
 
'''Note: You will have a lot of trouble using a [https://en.wikipedia.org/wiki/Softmodem softmodem/winmodem]! You are much better off using a hardware-based modem.'''<br />
 
<br />
 
I'll be using three external serial modems + USB-to-RS-232 adapters and one USB modem. Using dedicated serial hardware has the advantage of being easy to troubleshoot and scaling up to dozens of lines (if you have enough desk space and USB ports).<br />
 
  
 
== Setting up the Dial-in Server ==
 
== Setting up the Dial-in Server ==
  
The dial-in server will answer calls from the modems and act as a proxy for access to network resources.
+
The dial-in server will answer calls from the modems and act as a proxy for network resources.
  
 
=== Using a Raspberry Pi ===
 
=== Using a Raspberry Pi ===
Line 61: Line 89:
 
# Insert the SD card in your Raspberry Pi and connect the power and network cables
 
# Insert the SD card in your Raspberry Pi and connect the power and network cables
 
# Connect to the Raspberry Pi using SSH with the default username <code>pi</code> and password <code>raspberry</code>
 
# Connect to the Raspberry Pi using SSH with the default username <code>pi</code> and password <code>raspberry</code>
#* If you know the IP address of the Pi, you can connect to it directly using your operating system's built-in SSH client (or [https://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY] on Windows)
+
#* If you know the IP address of the Pi, you can connect to it directly using your operating system's built-in SSH client (on Windows, click [https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse here] for instructions to install openssh, or use a standalone client like [https://www.chiark.greenend.org.uk/~sgtatham/putty/ PuTTY])
 
#* If you don't know the IP address of the Pi, use a utility like [https://github.com/adafruit/Adafruit-Pi-Finder Adafruit's Pi Finder] to find its IP address and log in
 
#* If you don't know the IP address of the Pi, use a utility like [https://github.com/adafruit/Adafruit-Pi-Finder Adafruit's Pi Finder] to find its IP address and log in
  
 
=== Using a PC or other hardware ===
 
=== Using a PC or other hardware ===
  
Install a Debian-based Linux distribution of your choice before proceeding. Installation instructions are beyond the scope of this guide; you should consult your distribution's instructions for help ([https://help.ubuntu.com/ Ubuntu], [https://www.debian.org/releases/stable/installmanual Debian]).
+
Install a Linux or Unix distribution of your choice before proceeding. Installation instructions are beyond the scope of this guide; you should consult your distribution's instructions for help. The commands given in this guide may need to be changed if you're not using a Debian-derived Linux. Click these links for installation instructions for [https://help.ubuntu.com/ Ubuntu] and [https://www.debian.org/releases/stable/installmanual Debian]).
  
 
== The Telephone Network ==
 
== The Telephone Network ==
 
We need a way to connect our ISP modem to clients. There are many ways to approach this:
 
We need a way to connect our ISP modem to clients. There are many ways to approach this:
# Use the actual PSTN (i.e. real phone lines)
+
* Use the actual PSTN (real phone lines)
# Use a PBX to provide local connectivity
+
* Use a PBX to provide local connectivity
# Build your own circuity (not covered here as it would require extra configuration)
+
* Build your own circuity
# Build a fake PSTN using VoIP ATAs and a software PBX
+
* Build a fake PSTN using VoIP ATAs and a software PBX
  
I've gone with the fourth option. Here's the breakdown:
+
This guide builds a fake PSTN with SIP and ATAs. Here's the breakdown:
# Asterisk - a VoIP PBX - is configured on the dial-in server to accept connections from multiple SIP client accounts and route calls between them.
+
* Asterisk &mdash; a VoIP PBX on the dial-in server &mdash; accepts connections from multiple SIP client accounts and routes calls between them.
# Cisco-Linksys SPA-2102 ATA - which supports two phone lines - is set up as both of those SIP clients connected to the PBX.
+
* Cisco-Linksys SPA-2102 ATAs &mdash; which support two phone lines each &mdash; act as SIP clients connected to the PBX.
# The ISP-side modem(s) connect to one phone line, and a client device to a second line.
+
* The ISP-side modem(s) each connect to one phone line, and a client device to a second line.
  
This design can scale up to as many modems and clients as desired, just add more ATAs!
+
This design can scale up to as many modems and clients as desired: just add more ATAs!
  
 
==== Asterisk Setup ====
 
==== Asterisk Setup ====
 
<ol>
 
<ol>
<li>Install asterisk<br /></li>
+
<li>Install Asterisk:<br /></li>
 
<pre>
 
<pre>
sudo apt-get install asterisk</pre>
+
sudo apt install asterisk</pre>
 
</li>
 
</li>
<li>Append configuration for the SIP clients to the end of <code>/etc/asterisk/sip.conf</code>
+
<li>Append configuration for the SIP clients to the end of <code>/etc/asterisk/sip.conf</code>:
 
+
<br />
(4 modems and 4 clients on 4 ATAs)
+
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
This configuration is for 4 modems and 4 clients on 4 ATAs, but can be extended to as many or as few as you need.
 +
<div class="mw-collapsible-content">
 
<pre>
 
<pre>
 
[ata-modem1]
 
[ata-modem1]
Line 164: Line 194:
 
nat=no
 
nat=no
 
</pre>
 
</pre>
 +
</div>
 +
</div>
 
</li>
 
</li>
 
<li>Edit <code>/etc/asterisk/extensions.conf</code> and make two changes:<br />
 
<li>Edit <code>/etc/asterisk/extensions.conf</code> and make two changes:<br />
Search for <code>[default]</code> (should be around line 672) and comment out <br /><code>include => demo</code><br />
+
<ol><li>Search for <code>[default]</code> (should be around line 672) and comment out <code>include => demo</code> by prepending it with a semicolon (<code>;</code>)</li>
Underneath that line, add the new lines for the specific modems and the dial pool <br />
+
<li>Underneath that line, add the new lines for the specific modems and the dial pool:
 
<pre>
 
<pre>
 
exten => 881,1,Dial(SIP/ata-modem1, 30)
 
exten => 881,1,Dial(SIP/ata-modem1, 30)
Line 174: Line 206:
 
exten => 884,1,Dial(SIP/ata-modem4, 30)
 
exten => 884,1,Dial(SIP/ata-modem4, 30)
 
exten => _X!,1,Dial(SIP/ata-modem1&SIP/ata-modem2&SIP/ata-modem3&SIP/ata-modem4, 30)
 
exten => _X!,1,Dial(SIP/ata-modem1&SIP/ata-modem2&SIP/ata-modem3&SIP/ata-modem4, 30)
</pre><br />
+
</pre>
The _X! tells this dial plan rule to match any number a client dials and send the call to all of the ata-modem[1-4] clients simultaneously with a 30 second timeout.
+
The <code>_X!</code> tells this dial plan rule to match any number a client dials and send the call to all of the ata-modem[1-4] clients simultaneously with a 30 second timeout. To use a specific modemm, dial its extension and only that modem will ring.</li></ol>
If you want to use a specific modem dial its extension and only that modem will ring.
 
 
</li>
 
</li>
<li>Enable the asterisk service so it starts on boot<br />
+
<li>Enable the asterisk service so it starts on boot:<br />
 
<code>sudo systemctl enable asterisk</code><br />
 
<code>sudo systemctl enable asterisk</code><br />
 
</li>
 
</li>
 
<li>
 
<li>
Start Asterisk<br />
+
Start Asterisk:<br />
 
<code>sudo systemctl start asterisk</code></li>
 
<code>sudo systemctl start asterisk</code></li>
 
</ol>
 
</ol>
Line 188: Line 219:
 
==== ATA Configuration ====
 
==== ATA Configuration ====
  
Using a Unlocked SPA-2102. If your device is locked [http://www.toughdev.com/content/2012/06/unlocking-the-linksys-spa2102-phone-adapter/ follow these instructions]
+
These instructions use unlocked SPA-2102s with firmware versions 5.2.5 and 5.1.13. If your device is locked, [http://www.toughdev.com/content/2012/06/unlocking-the-linksys-spa2102-phone-adapter/ follow these instructions].
  
(Settings below are confirmed working on firmware firmware 5.2.5 and 5.1.13)
+
Client and modem lines are configured the same, just with different passwords.
  
 +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
Starting with a factory default configuration, to enable browser-based configuration:
 +
<div class="mw-collapsible-content">
 
Example of configuring a client line. (Same settings for modem line, just a different username/password)
 
Example of configuring a client line. (Same settings for modem line, just a different username/password)
  
Line 203: Line 237:
 
# Dial **** to enter the configuration menu
 
# Dial **** to enter the configuration menu
 
# Dial 110# to hear the IP address of your ATA
 
# Dial 110# to hear the IP address of your ATA
 +
</div>
 +
</div>
  
 +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
 +
Once browser-based configuration is enabled, navigate to the ATA's IP address and change the following options:
 +
<div class="mw-collapsible-content">
 
On a PC point your web browser at the IP of the ATA to load the web configuration.
 
On a PC point your web browser at the IP of the ATA to load the web configuration.
 
Several options need to be changed.
 
Several options need to be changed.
Line 232: Line 271:
 
# Click "Submit All Changes"
 
# Click "Submit All Changes"
  
Repeat for Line 2 if you need another line.
+
Repeat these instructions for Line 2 if you need to use both ports.
<br />
+
</div>
 +
</div>
  
When your ATA is first configured to connect to the SIP proxy (Asterisk) you will see output similar to this on the Asterisk console:
+
When your ATA first connects to the SIP proxy (Asterisk), you will see output like this on the Asterisk console (launched with <code>sudo asterisk -rvvvv</code>):
  
<code>sudo asterisk -rvvvv</code>
 
 
<pre>
 
<pre>
 
raspberrypi*CLI>  
 
raspberrypi*CLI>  
Line 247: Line 286:
  
 
<ol>
 
<ol>
<li>Open the Asterisk console to confirm your ATA lines are registered
+
<li>Open the Asterisk console (<code>sudo asterisk -rvvvv</code>) to confirm your ATA lines are registered:
 
 
<code>sudo asterisk -rvvvv</code>
 
  
 
<pre>raspberrypi*CLI> sip show peers
 
<pre>raspberrypi*CLI> sip show peers
Line 265: Line 302:
 
If you make changes to your configuration after starting Asterisk, you can use the <code>reload</code> command in the console to reload the configuration.</li>
 
If you make changes to your configuration after starting Asterisk, you can use the <code>reload</code> command in the console to reload the configuration.</li>
  
<li>Confirm clients can dial modems directly. Using a phone connected to one of the client lines dial 881# (the # tells the ATA you are done dialing), the first modem line should ring.</li>
+
<li>Confirm that clients can dial modems directly. Using a phone connected to one of the client lines, dial 881# (the # tells the ATA you are done dialing). The first modem line should ring.</li>
<li>Confirm clients can dial the modem pool. Dial 888# (or any number except the direct modem lines) and all modem lines should ring at once.
+
<li>Confirm that clients can dial the modem pool. Dial 888# (or any number except the direct modem lines): all modem lines should ring at once.
If you take a look at the asterisk console when dialing the pool you should see output like this:
+
If you take a look at the asterisk console when dialing the pool, you should see output like this:
 
<pre>
 
<pre>
 
raspberrypi*CLI>  
 
raspberrypi*CLI>  
Line 288: Line 325:
 
</li>
 
</li>
 
</ol>
 
</ol>
Congratulations! You now have your own voice network.<br />
+
'''Congratulations!''' You now have your own voice network.
  
 
== The Dial-in Server ==
 
== The Dial-in Server ==
 +
These instructions are specific to Debian-based Linux distributions, but should be similar for other distributions or Unixes.
 +
 
<ol>
 
<ol>
 
<li>Install your Debian-based Linux distribution of choice (Raspbian covered above)</li>
 
<li>Install your Debian-based Linux distribution of choice (Raspbian covered above)</li>
Line 298: Line 337:
 
sudo apt-get upgrade
 
sudo apt-get upgrade
 
sudo reboot</pre>
 
sudo reboot</pre>
<li>Connect a USB to RS-232 adapter and confirm it shows up as /dev/ttyUSBXXX (Run <code>ls /dev/</code> or <code>dmesg</code> to check). In my case, it presents as <code>/dev/ttyUSB0</code><br />
+
<li>Connect a USB to RS-232 adapter and confirm it shows up as /dev/ttyUSBXXX (Run <code>ls /dev/</code> or <code>dmesg</code> to check). In my case, it presents as <code>/dev/ttyUSB0</code>.<br />
My serial adapters are "<code>QinHeng Electronics HL-340 USB-Serial adaptor</code>" per <code>lsusb -v</code>
+
(My serial adapters are "<code>QinHeng Electronics HL-340 USB-Serial adaptor</code>" per <code>lsusb -v</code>.)
 
</li>
 
</li>
<li>Install ppp (and getty if your distro doesn’t have it by default)<br />
+
<li>Install ppp (and getty if your distribution doesn’t have it by default)<br />
 
<pre>sudo apt-get install ppp mgetty</pre></li>
 
<pre>sudo apt-get install ppp mgetty</pre></li>
 
<li>Create a systemd service for mgetty, by editing <code>/lib/systemd/system/[email protected]</code> (note the @) with your text editor of choice as root or sudo.
 
<li>Create a systemd service for mgetty, by editing <code>/lib/systemd/system/[email protected]</code> (note the @) with your text editor of choice as root or sudo.
Line 323: Line 362:
 
Configure mgetty by editing <code>/etc/mgetty/mgetty.config</code><br />
 
Configure mgetty by editing <code>/etc/mgetty/mgetty.config</code><br />
  
Comment out everything except the debug level, and append the section for configuring the serial devices:
+
Comment out everything except the debug level <!-- HOW???? -->, and append the section for configuring the serial devices:
  
I have 3 USB to serial devices (ttyUSB0, ttyUSB1, ttyUSB2) and one USB modem ttyACM0
+
I have 3 USB to serial devices (ttyUSB0, ttyUSB1, ttyUSB2) and one USB modem ttyACM0: <!-- You might want to collapse this. -->
  
 
<pre>debug 9
 
<pre>debug 9
Line 378: Line 417:
  
 
</pre>
 
</pre>
<br />
 
 
The <code>rings</code> parameter tells mgetty to answer the call after that many rings. They increase in the config so that all the modems dont try to answer at once, and you can prioritize which modems you want to be used most often.
 
The <code>rings</code> parameter tells mgetty to answer the call after that many rings. They increase in the config so that all the modems dont try to answer at once, and you can prioritize which modems you want to be used most often.
 
</li>
 
</li>
Line 465: Line 503:
 
lcp-echo-failure 60
 
lcp-echo-failure 60
 
</pre>
 
</pre>
It is important that the IP adresses do not overlap across the device configurations. I'm using small /30 subnets (4 IP addresses, 2 usable) to separate each client.
+
Ensure that the IP adresses do not overlap across the device configurations. I'm using small /30 subnets (4 IP addresses, 2 usable) to separate each client.
 
</li>
 
</li>
<li>Create the user for PAP authentication:<br /><code>sudo useradd -G dialout,dip,users -m -g users -s /usr/sbin/pppd dial</code></li>
+
<li>Create the user for PAP authentication: <code>sudo useradd -G dialout,dip,users -m -g users -s /usr/sbin/pppd dial</code></li>
<li>Set a password:<br /><code>sudo passwd dial</code></li> (I used dial, same as the username)
+
<li>Set a password: <code>sudo passwd dial</code></li>
 
<li>Edit <code>/etc/ppp/pap-secrets</code> and append the username and password (same as you entered above, quotes included):<br /> <code>dial    *              "dial"  *</code></li>
 
<li>Edit <code>/etc/ppp/pap-secrets</code> and append the username and password (same as you entered above, quotes included):<br /> <code>dial    *              "dial"  *</code></li>
<li>Enable packet forwarding for IP4 by editing <code>/etc/sysctl.conf</code>:<br /><code>net.ipv4.ip_forward=1</code><li>
+
<li>Enable packet forwarding for IP4 by appending <code>net.ipv4.ip_forward=1</code> to <code>/etc/sysctl.conf</code>.<!-- Don't you need to reload sysctl? Simply adding it to the file doesn't make it so without reloading or rebooting.--><li>
 
<li>
 
<li>
  
Line 483: Line 521:
 
</li>
 
</li>
 
</ol>
 
</ol>
 +
 +
<!-- I am judging you for not using (or even *mentioning*) IPv6. What has your employer done to you? -->
  
 
== Connecting with a client ==
 
== Connecting with a client ==
Line 488: Line 528:
 
Connect a client device to a client line on an ATA and configure it to use PPP authentication with the username <code>dial</code> and password <code>dial</code>
 
Connect a client device to a client line on an ATA and configure it to use PPP authentication with the username <code>dial</code> and password <code>dial</code>
  
To dial a specific modem use the number <code>881#</code> for modem one. To dial the modem pool dial any other number such as <code>888#</code>, <code>18008276364</code>, <code>17607067425</code> etc
+
To dial a specific modem use the number <code>881#</code> for modem one. To dial the modem pool dial any other number such as <code>888#</code>, <code>18008276364</code>, <code>17607067425</code>. <!-- This is not very internationalized and would seem arbitrary/confusing to thouse outside North America. -->
  
 
== Troubleshooting ==
 
== Troubleshooting ==
 
When using an external modem, the choice of USB to RS-232 adapter seems to be crucial. There aren't many requirements, but you must use an adapter that supports hardware flow control.
 
When using an external modem, the choice of USB to RS-232 adapter seems to be crucial. There aren't many requirements, but you must use an adapter that supports hardware flow control.
 +
 
If you need to purchase an adapter, you can either get one that explicitly says it supports hardware flow control ($$$), or play the eBay lottery and buy a half-dozen different models and hope one of them works.
 
If you need to purchase an adapter, you can either get one that explicitly says it supports hardware flow control ($$$), or play the eBay lottery and buy a half-dozen different models and hope one of them works.
<br /><br />
+
 
 
To troubleshoot modem communication and baud rate settings, use minicom (or screen) to open a session over serial and try different settings (or read your modem's manual!). Sending the command 'AT' followed by a new line should result in your modem replying 'OK'.<br />
 
To troubleshoot modem communication and baud rate settings, use minicom (or screen) to open a session over serial and try different settings (or read your modem's manual!). Sending the command 'AT' followed by a new line should result in your modem replying 'OK'.<br />
 
If you're getting nothing at all out of your modem, perform a [http://www.ni.com/tutorial/3450/en/ serial loopback test]
 
If you're getting nothing at all out of your modem, perform a [http://www.ni.com/tutorial/3450/en/ serial loopback test]
<br /><br />
+
 
 
If mgetty is not answering incoming calls, it may be having trouble communicating with your modem. Check the logs in <code>/var/log/mgetty/</code> to determine the problem. You may need to set a modem initialization string in the mgetty device config file, so check your modem's manual for help on this.
 
If mgetty is not answering incoming calls, it may be having trouble communicating with your modem. Check the logs in <code>/var/log/mgetty/</code> to determine the problem. You may need to set a modem initialization string in the mgetty device config file, so check your modem's manual for help on this.
<br /><br />
+
 
 
If you are having trouble with Asterisk please consult [https://www.voip-info.org/ voip-info.org] as Asterisk is quite complex and its troubleshooting is outside the scope of this guide.
 
If you are having trouble with Asterisk please consult [https://www.voip-info.org/ voip-info.org] as Asterisk is quite complex and its troubleshooting is outside the scope of this guide.
  
Line 531: Line 572:
 
     -- Channel SIP/ata-client3-00000005 left 'native_rtp' basic-bridge <3d2328ec-ef87-431e-be12-2dd9b84b6319>
 
     -- Channel SIP/ata-client3-00000005 left 'native_rtp' basic-bridge <3d2328ec-ef87-431e-be12-2dd9b84b6319>
 
   == Spawn extension (default, 888, 1) exited non-zero on 'SIP/ata-client3-00000005'
 
   == Spawn extension (default, 888, 1) exited non-zero on 'SIP/ata-client3-00000005'
       > 0x73a18d80 -- Strict RTP learning after remote address set to: 10.1.0.125:16386</pre><br />
+
       > 0x73a18d80 -- Strict RTP learning after remote address set to: 10.1.0.125:16386
 +
</pre>

Revision as of 00:42, 29 May 2020

Dial pool header.jpg


Dial-up internet connections may feel like a relic of the past, but modern telephony equipment makes it cheap & easy to set up your own dial-up ISP!

Forget about pricey interconnects with the phone company: with a few pieces of commodity hardware and an hour of setup, you can emulate a blazing fast 56 kbps network connection between two or more clients.


Requirements

Hardware Requirements

Hardware Requirements
Suggested hardware Used in this guide
Dial-in server Any computer that supports a Unix/Linux operating system Raspberry Pi 3 model B
Server modem(s) Any hardware modem(s) (see the Choosing Modem Hardware section below)
  • Matrix MX 14.4k Modem using XECOM XE1414 module (V.32) (datasheet)
  • USRobotics Sportster 0459 56k External Modem (only 28.8 up) (manual)
  • Practical Peripherals PM144MT II Modem (V.32)
  • USRobotics USR5637 USB 56k Modem (V.92) (datasheet)
Client device(s) Any computer with a dial-up modem Custom Windows 95 computer with a USRobotics Sportster 33.6k ISA modem
Telephony Any device that can emulate a telephone line 4x Linksys SPA-2102 analog telephone adapters (ATA) (don't stack these — they get hot!)
Connectors and adapters Whatever you need to connect the server modems to the dial-in server
  • 3x USB to RS-232 serial adapters (CH341 chipset)
  • 3x DE-9 to DB-25 serial adapters


Software Requirements
Suggested software Used in this guide
Dial-in server Any Linux/Unix operating system Debian Buster (Raspbian Lite release)
Telephony Real PSTN telephone lines, custom dial tone circuitry, or a software PBX Asterisk v16.2.1
Tunnelling daemon Any ppp daemon Samba ppp v2.4.7
Terminal manager Any terminal multiplexer with virtual terminal support mgetty v1.2.1

Choosing Modem Hardware

Despite variations in modem hardware, this guide should work with any dial-up modem that presents itself as a serial device to the operating system, whether it connects over USB, ISA, PCI, or RS-232.

However, you should avoid using software modems (sometimes called "softmodems" or "Winmodems") because they are error-prone and difficult to debug. This guide uses three external serial modems (with USB to RS-232 adapters) and one USB modem. Dedicated serial hardware is easy to troubleshoot, and scales to as many lines as you have USB ports.

Setting up the Dial-in Server

The dial-in server will answer calls from the modems and act as a proxy for network resources.

Using a Raspberry Pi

  1. Download the latest version of Raspbian Lite from raspberrypi.org and follow the installation instructions
  2. Before installing the SD card in your Raspberry Pi, enable SSH to avoid needed a mouse and keyboard:
    1. Mount the Raspberry Pi boot partition (most operating systems will do this automatically after writing the image)
    2. Create an empty file named ssh (with no extension) in the same folder as config.txt
    3. Safely eject the SD card
  3. Insert the SD card in your Raspberry Pi and connect the power and network cables
  4. Connect to the Raspberry Pi using SSH with the default username pi and password raspberry
    • If you know the IP address of the Pi, you can connect to it directly using your operating system's built-in SSH client (on Windows, click here for instructions to install openssh, or use a standalone client like PuTTY)
    • If you don't know the IP address of the Pi, use a utility like Adafruit's Pi Finder to find its IP address and log in

Using a PC or other hardware

Install a Linux or Unix distribution of your choice before proceeding. Installation instructions are beyond the scope of this guide; you should consult your distribution's instructions for help. The commands given in this guide may need to be changed if you're not using a Debian-derived Linux. Click these links for installation instructions for Ubuntu and Debian).

The Telephone Network

We need a way to connect our ISP modem to clients. There are many ways to approach this:

  • Use the actual PSTN (real phone lines)
  • Use a PBX to provide local connectivity
  • Build your own circuity
  • Build a fake PSTN using VoIP ATAs and a software PBX

This guide builds a fake PSTN with SIP and ATAs. Here's the breakdown:

  • Asterisk — a VoIP PBX on the dial-in server — accepts connections from multiple SIP client accounts and routes calls between them.
  • Cisco-Linksys SPA-2102 ATAs — which support two phone lines each — act as SIP clients connected to the PBX.
  • The ISP-side modem(s) each connect to one phone line, and a client device to a second line.

This design can scale up to as many modems and clients as desired: just add more ATAs!

Asterisk Setup

  1. Install Asterisk:
  2. sudo apt install asterisk
  3. Append configuration for the SIP clients to the end of /etc/asterisk/sip.conf:

    This configuration is for 4 modems and 4 clients on 4 ATAs, but can be extended to as many or as few as you need.

    [ata-modem1]
    context=default                 ; Using the default context because this is a simple design
    type=friend                     ; Allow calls to be placed and received to keep things simple
    secret=password                 ; Only the most secure passwords around here
    qualify=200                     ; Qualify peer is no more than 200ms away
    host=dynamic                    ; This device registers with us
    directmedia=yes                 ; Send RTP directly to the peer to reduce latency and jitter
    nat=no                          ; Only use symmetric IP routing
    
    [ata-modem2]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
    [ata-modem3]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
    [ata-modem4]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
    [ata-client1]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
    [ata-client2]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
    [ata-client3]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
    [ata-client4]
    context=default
    type=friend
    secret=password
    qualify=200
    host=dynamic
    directmedia=yes
    nat=no
    
  4. Edit /etc/asterisk/extensions.conf and make two changes:
    1. Search for [default] (should be around line 672) and comment out include => demo by prepending it with a semicolon (;)
    2. Underneath that line, add the new lines for the specific modems and the dial pool:
      exten => 881,1,Dial(SIP/ata-modem1, 30)
      exten => 882,1,Dial(SIP/ata-modem2, 30)
      exten => 883,1,Dial(SIP/ata-modem3, 30)
      exten => 884,1,Dial(SIP/ata-modem4, 30)
      exten => _X!,1,Dial(SIP/ata-modem1&SIP/ata-modem2&SIP/ata-modem3&SIP/ata-modem4, 30)
      
      The _X! tells this dial plan rule to match any number a client dials and send the call to all of the ata-modem[1-4] clients simultaneously with a 30 second timeout. To use a specific modemm, dial its extension and only that modem will ring.
  5. Enable the asterisk service so it starts on boot:
    sudo systemctl enable asterisk
  6. Start Asterisk:
    sudo systemctl start asterisk

ATA Configuration

These instructions use unlocked SPA-2102s with firmware versions 5.2.5 and 5.1.13. If your device is locked, follow these instructions.

Client and modem lines are configured the same, just with different passwords.

Starting with a factory default configuration, to enable browser-based configuration:

Example of configuring a client line. (Same settings for modem line, just a different username/password)

Lets start with factory default configuration and enabling web-based management.

  1. Connect a phone to LINE 1
  2. Dial **** to enter the configuration menu
  3. Dial 73738# then 1# then hang up. The unit is now factory reset
  4. Connect the Internet ethernet connection to your local network
  5. Dial **** to enter the configuration menu
  6. Dial 7932# then 1# then 1 then hang up. The web interface is now accessible from the 'Internet' side of the ATA
  7. Dial **** to enter the configuration menu
  8. Dial 110# to hear the IP address of your ATA

Once browser-based configuration is enabled, navigate to the ATA's IP address and change the following options:

On a PC point your web browser at the IP of the ATA to load the web configuration. Several options need to be changed.

  1. Click "Admin Login"
  2. Click "Advanced"
  3. (Optiona) Click "WAN Setup" if you need to change the IP address of the ATA
  4. Click the "Voice" tab
  5. Click "Line 1"
  6. Change "Network Jitter Level" to "extremely high" or "high"
  7. Change "Jitter Buffer Adjustment" to "disable"
  8. Set "Proxy" to the IP address of the Raspberry Pi running askterisk
  9. Set "User ID" to the username of the SIP user you are configuring, "ata-client3"
  10. Set "Password" to the password of that user
  11. Change "Call Waiting Serv" to "no"
  12. Change "Three Way Call Serv" to "no"
  13. Change "Preferred Codec" to "G711u"
  14. Change "Use Pref Codec Only" to "yes"
  15. Change "Silence Supp Enable" to "no"
  16. Change "Silence Threshold" to "high"
  17. Change "Echo Canc Enable" to "no"
  18. Change "Echo Canc Adapt Enable" to "no"
  19. Change "Echo Supp Enable" to "no"
  20. Change "FAX CED Detect Enable" to "no"
  21. Change "FAX CNG Detect Enable" to "no"
  22. Change "FAX Process NSE" to "no"
  23. Change "FAX Enable T38" to "no"
  24. Click "Submit All Changes"

Repeat these instructions for Line 2 if you need to use both ports.

When your ATA first connects to the SIP proxy (Asterisk), you will see output like this on the Asterisk console (launched with sudo asterisk -rvvvv):

raspberrypi*CLI> 
[Apr 27 04:08:29] NOTICE[573]: chan_sip.c:24884 handle_response_peerpoke: Peer 'ata-client1' is now Reachable. (13ms / 200ms)
[Apr 27 04:08:29] NOTICE[573]: chan_sip.c:24884 handle_response_peerpoke: Peer 'ata-client2' is now Reachable. (5ms / 200ms)

Verifying functionality

  1. Open the Asterisk console (sudo asterisk -rvvvv) to confirm your ATA lines are registered:
    raspberrypi*CLI> sip show peers
    Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description                      
    ata-client1/ata-client1   10.1.0.126                               D  No         No             5060     OK (7 ms)                                    
    ata-client2/ata-client2   10.1.0.126                               D  No         No             5061     OK (7 ms)                                    
    ata-client3/ata-client3   10.1.0.125                               D  No         No             5060     OK (9 ms)                                    
    ata-client4/ata-client4   10.1.0.125                               D  No         No             5061     OK (10 ms)                                   
    ata-modem1/ata-modem1     10.1.0.108                               D  No         No             5060     OK (8 ms)                                    
    ata-modem2/ata-modem2     10.1.0.108                               D  No         No             5061     OK (7 ms)                                    
    ata-modem3/ata-modem3     10.1.0.128                               D  No         No             5060     OK (7 ms)                                    
    ata-modem4/ata-modem4     10.1.0.128                               D  No         No             5061     OK (8 ms)                                    
    8 sip peers [Monitored: 8 online, 0 offline Unmonitored: 0 online, 0 offline]
    
    If you make changes to your configuration after starting Asterisk, you can use the reload command in the console to reload the configuration.
  2. Confirm that clients can dial modems directly. Using a phone connected to one of the client lines, dial 881# (the # tells the ATA you are done dialing). The first modem line should ring.
  3. Confirm that clients can dial the modem pool. Dial 888# (or any number except the direct modem lines): all modem lines should ring at once. If you take a look at the asterisk console when dialing the pool, you should see output like this:
    raspberrypi*CLI> 
      == Using SIP RTP CoS mark 5
           > 0x73a18d80 -- Strict RTP learning after remote address set to: 10.1.0.125:16386
        -- Executing [888@default:1] Dial("SIP/ata-client3-00000005", "SIP/ata-modem1&SIP/ata-modem2&SIP/ata-modem3&SIP/ata-modem4, 30") in new stack
      == Using SIP RTP CoS mark 5
      == Using SIP RTP CoS mark 5
      == Using SIP RTP CoS mark 5
      == Using SIP RTP CoS mark 5
        -- Called SIP/ata-modem1
        -- Called SIP/ata-modem2
        -- Called SIP/ata-modem3
        -- Called SIP/ata-modem4
        -- SIP/ata-modem3-00000008 is ringing
        -- SIP/ata-modem1-00000006 is ringing
        -- SIP/ata-modem4-00000009 is ringing
        -- SIP/ata-modem2-00000007 is ringing
    

Congratulations! You now have your own voice network.

The Dial-in Server

These instructions are specific to Debian-based Linux distributions, but should be similar for other distributions or Unixes.

  1. Install your Debian-based Linux distribution of choice (Raspbian covered above)
  2. Update to latest packages and reboot if required
  3. sudo apt-get update
    sudo apt-get upgrade
    sudo reboot
  4. Connect a USB to RS-232 adapter and confirm it shows up as /dev/ttyUSBXXX (Run ls /dev/ or dmesg to check). In my case, it presents as /dev/ttyUSB0.
    (My serial adapters are "QinHeng Electronics HL-340 USB-Serial adaptor" per lsusb -v.)
  5. Install ppp (and getty if your distribution doesn’t have it by default)
    sudo apt-get install ppp mgetty
  6. Create a systemd service for mgetty, by editing /lib/systemd/system/[email protected] (note the @) with your text editor of choice as root or sudo.
    [Unit]
    Description=External Modem %I
    Documentation=man:mgetty(8)
    Requires=systemd-udev-settle.service
    After=systemd-udev-settle.service
    
    [Service]
    Type=simple
    ExecStart=/sbin/mgetty /dev/%i
    Restart=always
    PIDFile=/var/run/mgetty.pid.%i
    
    [Install]
    WantedBy=multi-user.target
    
  7. Configure mgetty by editing /etc/mgetty/mgetty.config
    Comment out everything except the debug level , and append the section for configuring the serial devices: I have 3 USB to serial devices (ttyUSB0, ttyUSB1, ttyUSB2) and one USB modem ttyACM0:
    debug 9
    
    port ttyUSB0
     port-owner root
     port-group dialout
     port-mode 0660
     data-only yes
     ignore-carrier no
     toggle-dtr yes
     toggle-dtr-waittime 500
     rings 1
     speed 115200
     modem-check-time 160
    
    port ttyUSB1
     port-owner root
     port-group dialout
     port-mode 0660
     data-only yes
     ignore-carrier no
     toggle-dtr yes
     toggle-dtr-waittime 500
     rings 2
     speed 115200
     modem-check-time 60
    
    port ttyUSB2
     port-owner root
     port-group dialout
     port-mode 0660
     data-only yes
     ignore-carrier no
     toggle-dtr yes
     toggle-dtr-waittime 500
     rings 3
     speed 115200
     modem-check-time 60
    
    port ttyACM0
     port-owner root
     port-group dialout
     port-mode 0660
     data-only yes
     ignore-carrier no
     toggle-dtr yes
     toggle-dtr-waittime 500
     rings 4
     speed 115200
     modem-check-time 60
    
    

    The rings parameter tells mgetty to answer the call after that many rings. They increase in the config so that all the modems dont try to answer at once, and you can prioritize which modems you want to be used most often.

  8. Enable the mgetty service so it starts on boot for each device:
    sudo systemctl enable [email protected]
    sudo systemctl enable [email protected]
    sudo systemctl enable [email protected]
    sudo systemctl enable [email protected]

  9. Start mgetty:
    sudo systemctl start [email protected]
    sudo systemctl start [email protected]
    sudo systemctl start [email protected]
    sudo systemctl start [email protected]
  10. Configure ppp by editing /etc/ppp/options
    Like above, comment out everything except these settings:
    # Define the DNS server for the client to use
    ms-dns 8.8.8.8
    # async character map should be 0
    asyncmap 0
    # Require authentication
    auth
    # Use hardware flow control
    crtscts
    # We want exclusive access to the modem device
    lock
    # Show pap passwords in log files to help with debugging
    show-password
    # Require the client to authenticate with pap
    +pap
    # If you are having trouble with auth enable debugging
    debug
    # Heartbeat for control messages, used to determine if the client connection has dropped
    lcp-echo-interval 30
    lcp-echo-failure 4
    # Cache the client mac address in the arp system table
    proxyarp
    # Disable the IPXCP and IPX protocols.
    noipx
    
  11. Create a device option file for each device by editing:
    /etc/ppp/options.ttyUSB0
    local
    lock
    nocrtscts
    192.168.32.1:192.168.32.2
    netmask 255.255.255.252
    noauth
    proxyarp
    lcp-echo-failure 60
    


    /etc/ppp/options.ttyUSB1

    local
    lock
    nocrtscts
    192.168.32.5:192.168.32.6
    netmask 255.255.255.252
    noauth
    proxyarp
    lcp-echo-failure 60
    

    /etc/ppp/options.ttyUSB2

    local
    lock
    nocrtscts
    192.168.32.9:192.168.32.10
    netmask 255.255.255.252
    noauth
    proxyarp
    lcp-echo-failure 60
    

    /etc/ppp/options.ACM0

    local
    lock
    nocrtscts
    192.168.32.13:192.168.32.14
    netmask 255.255.255.252
    noauth
    proxyarp
    lcp-echo-failure 60
    

    Ensure that the IP adresses do not overlap across the device configurations. I'm using small /30 subnets (4 IP addresses, 2 usable) to separate each client.

  12. Create the user for PAP authentication: sudo useradd -G dialout,dip,users -m -g users -s /usr/sbin/pppd dial
  13. Set a password: sudo passwd dial
  14. Edit /etc/ppp/pap-secrets and append the username and password (same as you entered above, quotes included):
    dial * "dial" *
  15. Enable packet forwarding for IP4 by appending net.ipv4.ip_forward=1 to /etc/sysctl.conf.
  16. The last step for the dial-up server is to configure the firewall to allow traffic forwarding from PPP out onto the network (and off to the Internet).
    1. On Linux distributions with iptables, you need to add a line to /etc/rc.local to enable masquerading. If your Ethernet interface is named eth0, you would add this line:
      iptables -t nat -A POSTROUTING -s 192.168.32.0/24 -o eth0 -j MASQUERADE
    2. On modern Ubuntu installs, ufw is used as a frontend to iptables, so the procedure is a bit different. Follow this guide, but you can omit -o eth0 and use -s 192.168.32.0/24.


Connecting with a client

Connect a client device to a client line on an ATA and configure it to use PPP authentication with the username dial and password dial

To dial a specific modem use the number 881# for modem one. To dial the modem pool dial any other number such as 888#, 18008276364, 17607067425.

Troubleshooting

When using an external modem, the choice of USB to RS-232 adapter seems to be crucial. There aren't many requirements, but you must use an adapter that supports hardware flow control.

If you need to purchase an adapter, you can either get one that explicitly says it supports hardware flow control ($$$), or play the eBay lottery and buy a half-dozen different models and hope one of them works.

To troubleshoot modem communication and baud rate settings, use minicom (or screen) to open a session over serial and try different settings (or read your modem's manual!). Sending the command 'AT' followed by a new line should result in your modem replying 'OK'.
If you're getting nothing at all out of your modem, perform a serial loopback test

If mgetty is not answering incoming calls, it may be having trouble communicating with your modem. Check the logs in /var/log/mgetty/ to determine the problem. You may need to set a modem initialization string in the mgetty device config file, so check your modem's manual for help on this.

If you are having trouble with Asterisk please consult voip-info.org as Asterisk is quite complex and its troubleshooting is outside the scope of this guide.

That said here is a successful call to 888 (pool) as an example:

raspberrypi*CLI> 
  == Using SIP RTP CoS mark 5
       > 0x73a18d80 -- Strict RTP learning after remote address set to: 10.1.0.125:16386
    -- Executing [888@default:1] Dial("SIP/ata-client3-00000005", "SIP/ata-modem1&SIP/ata-modem2&SIP/ata-modem3&SIP/ata-modem4, 30") in new stack
  == Using SIP RTP CoS mark 5
  == Using SIP RTP CoS mark 5
  == Using SIP RTP CoS mark 5
  == Using SIP RTP CoS mark 5
    -- Called SIP/ata-modem1
    -- Called SIP/ata-modem2
    -- Called SIP/ata-modem3
    -- Called SIP/ata-modem4
    -- SIP/ata-modem3-00000008 is ringing
    -- SIP/ata-modem1-00000006 is ringing
    -- SIP/ata-modem4-00000009 is ringing
    -- SIP/ata-modem2-00000007 is ringing
       > 0x73a31a78 -- Strict RTP learning after remote address set to: 10.1.0.108:16386
    -- SIP/ata-modem2-00000007 answered SIP/ata-client3-00000005
    -- Channel SIP/ata-modem2-00000007 joined 'simple_bridge' basic-bridge <3d2328ec-ef87-431e-be12-2dd9b84b6319>
    -- Channel SIP/ata-client3-00000005 joined 'simple_bridge' basic-bridge <3d2328ec-ef87-431e-be12-2dd9b84b6319>
       > Bridge 3d2328ec-ef87-431e-be12-2dd9b84b6319: switching from simple_bridge technology to native_rtp
       > Remotely bridged 'SIP/ata-client3-00000005' and 'SIP/ata-modem2-00000007' - media will flow directly between them
       > 0x73a31a78 -- Strict RTP learning after remote address set to: 10.1.0.108:16386
       > 0x73a18d80 -- Strict RTP learning after remote address set to: 10.1.0.125:16386
[call proceeds then ends below]
    -- Channel SIP/ata-modem2-00000007 left 'native_rtp' basic-bridge <3d2328ec-ef87-431e-be12-2dd9b84b6319>
    -- Channel SIP/ata-client3-00000005 left 'native_rtp' basic-bridge <3d2328ec-ef87-431e-be12-2dd9b84b6319>
  == Spawn extension (default, 888, 1) exited non-zero on 'SIP/ata-client3-00000005'
       > 0x73a18d80 -- Strict RTP learning after remote address set to: 10.1.0.125:16386