SIP and IAX remote extensions with two separate systems
I've done this (after a
lot of trial and error) with both SIP and IAX2. Here are the highlights:
SIP METHOD:
Office router: forward ports 5060-5082 and 10000-20000 (all of them UDP only) to your PiaF server. I suggest you create a dynamic dns updater at the office so you can use a name instead of an IP in the config below. For this example, I'll use myoffice.dyndns.org.
Set up a SIP extension at the office with the extension number and secret that you want (for this example, I'll use extension 413 and secret "notverysecurehere"). Make sure NAT is set to YES. For now, don't change anything else. Save and apply.
On your home system, set up a SIP trunk with the following settings:
Trunk Name: worksiptrunk
PEER Details:
canreinvite=no
context=from-trunk
dtmfmode=rfc2833
fromuser=413
host=myoffice.dyndns.org
insecure=very
qualify=yes
secret=notverysecurehere
type=friend
username=413
USER Context: 413
User Details:
host=myoffice.dyndns.org
Register String:
413:
[email protected]/413
Create an outbound route that will allow you to call out this trunk. For example, if you want to always dial a 9 before the numbers into the office, make the dial pattern 9|X. for this route, and set the trunk to worksiptrunk.
If you only want to dial internal office numbers, change this pattern accordingly (for example, if all your internal extensions were 3 digits and started with a 4, your dial pattern could be 4XX and only calls with this pattern will match this outbound route).
Create an inbound route named Work Office Line with the following settings:
DID Number: 413
Caller ID Number: (leave this blank)
Set the destination to the extension or ring group that you would like to receive calls. I use a time condition so my home extension won't ring late in the evening.
If you like, you can use the CallerID name prefix to add "Work-" or something in front of the caller ID of calls received through this trunk.
IAX2 METHOD:
I think I actually had more luck doing trunk peering rather than an actual IAX extension, so give this a shot:
On both ends, open up port 4569 (UDP) and point it to the servers. Note on the SIP configuration above, no ports needed to be opened on the "home" system. On this configuration, I've also set up a dynamic DNS name for the home system as well, myhome.dyndns.org.
On the office system, create an IAX2 trunk with the following:
Trunk Name: home-peer
PEER Details:
context=from-internal
host=myhome.dyndns.org
qualify=yes
secret=notverysecurehere
trunk=yes
type=peer
username=work-user
USER Context: home-user
USER Details:
context=from-internal
host=myhome.dyndns.org
qualify=yes
secret=notverysecurehere
trunk=yes
type=user
Register String: (leave blank)
On the home system, create an IAX2 trunk with the following:
Trunk Name: work-peer
PEER Details:
username=home-user
type=peer
trunk=yes
secret=notverysecurehere
qualify=yes
host=myoffice.dyndns.org
context=from-internal
USER Context: work-user
USER Details:
type=user
trunk=yes
secret=notverysecurehere
qualify=yes
host=myoffice.dyndns.org
context=from-internal
Register String: (leave blank)
Before you go any further, login to each machine, run asterisk (asterisk -r) and run the command "iax2 show peers" to confirm that the two boxes are talking. If the trunk doesn't show up as OK (with a time delay in milliseconds) then go check the settings before continuing.
On the office system, create a CUSTOM extension (413) with the following dial string (assuming your home office extension is 250):
IAX2/home-peer/250
So now when you dial 413 from the office, your home extension 250 should ring.
Finally, create an outbound route that will allow you to call out this trunk (to the office). For example, if you want to always dial a 9 before the numbers into the office, make the dial pattern 9|X. for this route, and set the trunk to work-peer.
If you only want to dial internal office numbers, change this pattern accordingly (for example, if all your internal extensions were 3 digits and started with a 4, your dial pattern could be 4XX and only calls with this pattern will match this outbound route).
Disclaimer:
Hopefully I've covered everything for each configuration. If not, reply and I'll try to clarify or add whatever might be missing. This configuration is taken from my live, working system, so I know it works (unless I missed something

).