This is how we configure outside PSTN access or dialing through another SIP trunk. Beware that this a simplistic example that neglects most security including SRTP
First you'll need to be in config mode:
There are more options but for now we'll just focus on security/allowing connections to and from our phones and the trunk.
Router(config)#voice service voip
Then enter the trusted IP list:
Router(conf-voi-serv)#ip address trusted list
Set Trusted IPs:
In practice you would set the static IPs/ranges of your SIP trunk(s)
o be easy/insecure for testing just set any IP as being trusted (for trusted/LAN/testing only!)
Router(cfg-iptrust-list)#ipv4 0.0.0.0 0.0.0.0
To set a specify IP
This could be one of your SIP trunk IPs
Router(cfg-iptrust-list)#ipv4 192.168.5.20 255.255.255.0
To set a range (/24):
This may be a range of phones on your internal network that you want to trust.
Router(cfg-iptrust-list)#ipv4 10.0.0.0 255.255.255.0
You can add more entries as needed.
We'll set our preferred codec list
Router(config)#voice class codec 1
Router(config-class)#codec preference 1 g711ulaw
Router(config-class)#codec preference 2 g729r8
Go back to config mode:
Here is how we setup our trunk, depending on your service provider it may have different requirements (most providers will provide example configs).
Basically we are just authenticating using our username and password from our SIP provider and the last part "realm" is the IP or domain of the server.
authentication command will use the default username/password when authenticating.
credentials command is really the same but you can have multiple of these (eg. if you have accounts with multiple SIP trunks/providers).
Router(config)#sip-ua
Router(config-sip-ua)#credentials username YOUR-USERNAME password 0 YOUR-PASSWORD realm IP-or-domain-of-Trunk.com
There is another option for credentials which can specify a specific phone number tied to the account (some providers do this and some may not).
Router(config-sip-ua)#credentials number 1234 username YOUR-USERNAME password 0 YOUR-PASSWORD realm IP-or-domain-of-Trunk.com
Router(config-sip-ua)#authentication username YOUR-USERNAME password 0 YOUR-PASSWORD realm IP-or-domain-of-Trunk.com
This is a generic use the trunk for all non-local calls, but in practice, you may have many providers and may have a more specific dial pattern so perhaps calls for country ABC go through dialpeer 4444 to give better or cheaper calls to a specific destination.
Be in config mode
In our example we call our dial-peer "123" but it could be any unused number.
Create the dial-peer
Router(config)#dial-peer voice 123 voip
We set destination pattern as anything starting with a 9 (the idea is that 9 is for dialing out, change according to your needs).
Router(config-dial-peer)#destination-pattern 9T
We set the protocol as sip, since we use this protocol for a SIP trunk of course.
Router(config-dial-peer)#session protocol sipv2
We set the codec, a very standard g711ulaw, but change according to your needs (what your provider also must support).
Router(config-dial-peer)#codec g711ulaw
Set callerid (usually should be the number your provider assigned):
In this example we set callerid as "12345678"
Router(config-dial-peer)#clid network-number 12345678
Set your session target
It's Cisco talk about which IP/domain do we send the calls to when this dial-peer is matched?
You can use a hostname like this
Router(config-dial-peer)#session target dns:your-server-domain
Or preferably if they have a static IP use this:
Router(config-dial-peer)#session target ipv4:192.168.5.254
cisco, cme, configure, sip, voipthis, pstn, dialing, ll, config, mode, voip, router, ip, conf, voi, serv, ips, static, ranges, insecure, lan, cfg, iptrust, ipv, specify, entries,