SIP with Clearmode on Cisco ISR

In this blog post i will try to explain how to configure a Cisco ISR device like the ISR 3825 to use the Clearmode codec to for ISDN traffic over SIP to another device.
Clearmode is in simple terms the 64kbit ISDN B channel converted to an RTP stream. Same data but repackaged for transport over IP. The cisco variant of clearmode is called clear-channel and the routers can be configured to use Clearmode/RFC 4040 instead.
A simple unauthenticated SIP trunk to Asterisk
This configuration enables SIP on the interface GigabitEthernet0/0 and routes 7 digit long phone numbers to IP 1.2.3.4. I'm from Europe so I prefer alaw. I use this kind of fonfiguration on my Cisco ISR 3825 running IOS 15.1(4)M9
voice service voip
no ip address trusted authenticate
allow-connections sip to sip
fax protocol none
modem passthrough nse codec g711alaw
sip
bind control source-interface GigabitEthernet0/0
bind media source-interface GigabitEthernet0/0
!
voice class codec 1
codec preference 1 g711alaw
codec preference 2 g711ulaw
!
dial-peer voice 1234 voip
description Cool peer 1234
destination-pattern 1234...
session protocol sipv2
session target ipv4:1.2.3.4
voice-class codec 1
dtmf-relay rtp-nte
no vad
!
Adding Clearmode
voice service voip
sip
bearer-capability clear-channel udi
encap clear-channel standard
!
voice class codec 1
codec preference 3 clear-channel
!
bearer-capability clear-channel udi
enables clear-channel codec to UDI bearer capability mapping and UDI bearer capability to clear-channel codec mapping.
encap clear-channel standard
enables RFC 4040-based clear-channel codec negotiation for SIP calls. Without this line the calls will not work with non cisco SIP connections.
codec preference 3 clear-channel
adds clearmode support to the codec list