Log in to VoIP.ms and navigate to DID Numbers -> Manage DID(s)
Look for the DID you want to use for the trunk and note the number, routing, and POP.
![Elastix Elastix](https://gerakanopensource.files.wordpress.com/2016/07/setting-trunk-trixbox1.jpg)
In FreePBX, navigate to Connectivity -> Trunks
Click +Add Trunk -> +Add SIP (chan_pjsip) Trunk. PJSIP simplifies the setup from the PBX side and is the new default for Asterisk. You can read all about it straight from Digium if you want.
Fill out the General tab as desired. Note the outbound Caller ID format and also set a reasonable maximum channels value to protect against extreme charges if a SIP user's credentials are ever compromised. I generally leave the Caller ID blank and set it on the outbound routes, but it is easy to miss there.
Leave the Dialed Number Manipulation Rules empty. I always recommend handling that on the outbound route(s).
Go to asterisk - FreePBX, then click Setup, and click Trunks. Click add SIP trunks, and in General Settings enter your PSTN incoming number received from. Then watch while TrixBox loads CentOS/4.3 and all the Asterisk and Linux. We'll show you how to set up an incoming and an outgoing VoIP trunk so you can.
Fill out the General tab on PJSIP Settings with your voip.ms information noted from above. The username is the account number, or if you use a sub account it is the account number _subaccountname. The secret is the password for the account on VoIP.ms. The SIP server is the pop name with the dash removed and .voip.ms appended.
Click to the advanced tab
Scroll to the bottom and change detect fax to enabled if you want to enable inbound faxing on this trunk. VoIP.ms does not support T.38 FoIP but faxing over SIP works for most simple needs.
You can leave the codecs tab alone unless you have changed default codecs on VoIP.ms side.
Click submit at the bottom of the screen, and then after it finishes, click the red Apply Config button.
Go back to the FreePBX dashboard and you should see the trunk online after you click the little circle arrows to refresh.
Part of the FreePBX 13 Setup Guide