Dial-up pool
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.
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.
TODO SWAP OUT IMAGE
Contents
Prerequisites
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 a modem 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)
The hardware I've chosen to use is:
- Raspberry Pi 3B
- 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)
- 3x USB to RS-232 serial adapters, ch341 chipset
- 3x DE-9 to DB-25 serial adapters
- 4x Linksys SPA-2102 analog telephone adapter (ATA)
Software Requirements
- Raspbian, Debian, Ubuntu, or any modern Debian based Linux distribution
- 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.22, V.32, etc.).
This tutorial 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.
Note: You will have a lot of trouble using a softmodem/winmodem! You are much better off using a hardware-based modem.
I'll be using an external serial modem + USB-to-RS-232 adapter for this tutorial. 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).
My modem is an MX Modem made by MATRIX, but I was unable to find any information about it. Obviously the next step was to crack it open to figure out its capabilities.
Inside is a XECOM XE1414C 14.4 kbps modem in a single component package. The PDF manual is here.
To connect the modem to the ISP-side computer, I'm using a generic USB to RS-232 adapter and a DE-9 to DB-25 adapter.
Note: Tutorial will be updated with USB modem support soon.
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 (i.e. real phone lines)
- Use a PBX to provide local connectivity
- Build your own circuity (not covered here as it would require extra configuration)
- Build a fake PSTN using VoIP ATAs and a software PBX
I've gone with the fourth option. Here's the breakdown:
- Asterisk - a VoIP PBX - is configured on the dial-in server to accept connections from two SIP client accounts and route calls between them.
- A Linksys PAP2T ATA - which supports two phone lines - is set up as both of those SIP clients connected to the PBX.
- The ISP-side modem is connected to the first line, and the client device to the second line.
Asterisk Setup
- Install asterisk
- Append configuration for the SIP clients to the end of
/etc/asterisk/sip.conf
[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
- Edit
/etc/asterisk/extensions.conf
and make two changes:
Search for[default]
(should be around line 672) and comment outinclude => demo
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. If you want to use a specific modem dial its extension and only that modem will ring.
- Enable the asterisk service so it starts on boot
sudo systemctl enable asterisk
-
Start Asterisk
sudo systemctl start asterisk
- Open the Asterisk console to confirm your ATA lines are registered
sudo asterisk -rvvvv
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.
sudo apt-get install asterisk
ATA SIP registration example:
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)
Successful call to 888 (pool) 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
ATA Configuration
I won't go into much detail on ATA configuration since the topic has been beaten to death on various forums. This is the process to get basic communication:
- Set up both lines on the ATA to register to the PBX with usernames 'pap2t-ispmodem' and 'pap2t-client' and the password 'password'
- Use the G.711 µ-law codec
- Disable every echo cancellation option in your ATA (see here for PAP2T instructions)
- Set the jitter buffer to be as small as possible
Congratulations! You now have your own voice network.
The Dial-in Server
- Install your Debian-based Linux distribution of choice (not covered here)
- Update to latest packages and reboot if required
- Connect the USB to RS-232 adapter and confirm it shows up as /dev/ttyUSBXXX (
ls /dev/
to check). In my case, it presents as/dev/ttyUSB0
My serial adapter is a "ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adaptor
" - Install ppp (and getty if your distro doesn’t have it by default)
sudo apt-get install ppp mgetty
- Many of the old guides were written when inittab was still around, but it's 2019 and systemd has taken over.
We need to create a systemd service for mgetty, so edit/lib/systemd/system/[email protected]
(note the @) with your text editor of choice as root.[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
-
Configure mgetty by editing
/etc/mgetty/mgetty.config
with your text editor of choice as root.
Comment out everything except the debug level, and append the section for configuring the serial device: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
- Enable the mgetty service so it starts on boot:
sudo systemctl enable [email protected] sudo systemctl enable [email protected] sudo systemctl enable [email protected] sudo systemctl enable [email protected]
-
Start mgetty:
sudo systemctl start [email protected] sudo systemctl start [email protected] sudo systemctl start [email protected] sudo systemctl start [email protected]
- 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
- Create a device option file 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
- Create the user for PAP authentication:
sudo useradd -G dialout,dip,users -m -g users -s /usr/sbin/pppd dial
- Set a password:
sudo passwd dial
(I used dial, same as the username)
- Edit
/etc/ppp/pap-secrets
and append the username and password (same as you entered above, quotes included):
dial * "dial" *
- Enable packet forwarding for IP4 by editing
/etc/sysctl.conf
:net.ipv4.ip_forward=1
-
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).
- 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
-
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
.
- On Linux distributions with iptables, you need to add a line to
sudo apt-get update sudo apt-get upgrade sudo reboot
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.
I ran into a bug in Debian 9.5 with my USB to serial adapter using the ch341 driver, where setting the baud rate was not working on some Linux kernels. (Seems to be this bug)
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.