For a while now, every Internet package I have subscribed to at home comes with a phone line that I never end up utilizing. Occasionally I’ll hook a modem up to it to test something, but for the most part it sits idle. I am always running an asterisk-based PBX at home however, and since I have this home phone line “for free” I might as well use it as a dial-in for my exchange. I’m not an asterisk expert and this ended up taking me a while to figure out, but it only takes a small amount of configuration to accomplish.

To do this, I utilized an Obihai OBi110 ATA which is fairly inexpensive to get and features both an FX0 port for the phone line and an FXS port for a phone. The inclusion of the FXS port makes this ATA appealing, especially for someone just starting out with a PBX, but the FXO port is what we want and we can hook it right up to the phone line.

The Obi110.

The Obi110.

The asterisk configuration for adding this SIP line is fairly similar to what you would do for any sort of SIP phone you are trying to connect. In the sip.conf I have the following (note that I use a template for my SIP peers, and some config may be unnecessary for the pots user we are focusing on):

[lines](!) ; template for all user logins (e.g. ATAs)
type = peer
host = dynamic
disallow=all
;allow=g722
allow=ulaw
allow=alaw
qualify = yes
insecure = port,invite
canreinvite = no ; don't allow RTP voice traffic to bypass Asterisk
progressinband = yes
directmedia=no ; direct media is generally undesired, and can cause one-way audio issues
call-limit=2
transport=udp,tcp,tls ; list of protocols allowed
busylevel=1
trust_id_outbound = no

[pots](lines)
secret=yoursecretpassword
host=dynamic
type=friend
context=from-pots
qualify=yes
canreinvite=no
allow=all

From the above config you can see that I have a context associated with this user called from-pots that we need to define in our dialplan. In my extensions.conf file I have the context defined as shown:

[from-pots]
exten => 5551112222,1,NoOP() ; Replace with your home phone #
        same => n,Answer()
        same => n,Dial(LOCAL/${OC1}7111@phreaknet-exchange) ; The destination
        same => n,Hangup()

This will take the call, mark it as originating from my home phone number, and send it to my DISA. You could easily replace the destination with something else on your switch or a specific ATA extension if you’d prefer.

This will take care of calls coming in, but we also want to handle calls going out. To do this, we can just add some config for our SIP peers that are hooked up to actual phones. Each of my peers in sip.conf that actually corresponds to a phone will use the content from-internal and you likely already have some context defined here that you can modify. We can add something like the following to the existing context that will allow calls to go out over the home phone line provided the dialer prefix their destination number with “91” to get an outside line:

[from-internal]
exten => _91NXXNXXXXXX,1,NoOp()
        same => n,Dial(SIP/pots/${EXTEN:2})
        same => n,Playtones(congestion)
        same => n,Hangup()

On the OBi110 itself, we just add in the credentials we defined in sip.conf (pots/yoursecretpassword), the IP/port of the PBX, and a few other assorted options as shown below:

Service Providers --> ITSP Profile B --> SIP
SIP:
ProxyServer 192.168.3.2
ProxyServerPort 5061

Voice Services --> SP2 Service
SP2 Service:
Enable (checked)
X_ServProvProfile B
X_InboundCallRoute LI

Sip Credentials:
AuthUserName pots
AuthPassword yoursecretpassword

Physical Interfaces --> Line Port
Line Port:
InboundCallRoute SP2(5551112222)

After saving and rebooting on the Obi110, things should be good to go as long as the ATA can successfully register with asterisk. You can always check registration through asterisk like this:

# asterisk -rvvvvv
Asterisk 18.10.1, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 18.10.1 currently running on rpi-pbx-phreaknet (pid = 720)
rpi-pbx-phreaknet*CLI> sip show peers like pots
Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description
pots/pots                 192.168.3.101                            D  Yes        Yes            5061     OK (5 ms)   
1 sip peers [Monitored: 1 online, 0 offline Unmonitored: 0 online, 0 offline]

That’s it. Give your home phone number a call and see if it properly routes you to wherever you configured, then try calling out from a phone on your PBX.

Troubleshooting is easily done by running asterisk -rvvvvv in your console while making a call to see what is happening on the PBX in real time.