title: Asterisk No domain-name found in URI
body: <p>I'm trying to get Asterisk working with Bahnhof IP telephony provider here in Sweden. They don't officially support third party solutions but that have never stopped me before.</p>
  
  <p>Anyhow to the nitty gritty, the VoIP linux (Debian 7) running Asterisk 11.5.1 has the public IP on interface eth1, the firewall (iptables) is fully opened between the box and Bahnhof VoIP servers. Incoming calls are working. Outgoing are not as shown in the log below. I've search the web from top to bottom and have zip about this issue.</p>
  
  <p>I have another provider (CellIP) which works just fine with these same settings, I've never received any 404 messages like below from them.</p>
  
  <p><strong>sip.conf</strong></p>
  
  <pre><code>...
  [bahnhof]
  type=peer
  defaultuser=55500XXXXXX
  fromuser=55500XXXXXX
  context=default
  secret=mypassword
  host=bahnhof-lda.soho1.voip.bahnhof.net
  fromdomain=bahnhof-lda.soho1.voip.bahnhof.net
  insecure=port,invite
  qualify=yes
  canreinvite=no
  dtmfmode=rfc2833
  ...
  </code></pre>
  
  <p><strong>extensions.conf</strong></p>
  
  <pre><code>...
  [010XXXXXXX-out]
  exten =&gt; _0X.,1,Set(CALLERID(num)=55500XXXXXX)
  exten =&gt; _0X.,n,Dial(SIP/${EXTEN}@bahnhof,30,trg)
  exten =&gt; _0X.,n,Hangup()
  ...
  </code></pre>
  
  <p><strong>SIP DEBUG</strong></p>
  
  <pre><code>&lt;------------&gt;
  Audio is at 10060
  Adding codec 0x100 (g729) to SDP
  Adding codec 0x2 (gsm) to SDP
  Adding codec 0x4 (ulaw) to SDP
  Adding codec 0x8 (alaw) to SDP
  Adding non-codec 0x1 (telephone-event) to SDP
  Reliably Transmitting (no NAT) to 77.240.208.105:5060:
  INVITE sip:0700XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net SIP/2.0
  Via: SIP/2.0/UDP 81.170.XXX.XXX:5060;branch=z9hG4bK4db8a605
  Max-Forwards: 70
  From: "0700XXXXXX" &lt;sip:55500XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net&gt;;tag=as5eaad2ef
  To: &lt;sip:0700XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net&gt;
  Contact: &lt;sip:55500XXXXXX@81.170.XXX.XXX:5060&gt;
  Call-ID: 498e8f9616aadc0a658b301909fe58d7@bahnhof-lda.soho1.voip.bahnhof.net
  CSeq: 102 INVITE
  User-Agent: Asterisk PBX 1.8.11.0
  Date: Wed, 16 Oct 2013 15:18:57 GMT
  Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
  Supported: replaces, timer
  Content-Type: application/sdp
  Content-Length: 360
  
  v=0
  o=root 495353330 495353330 IN IP4 81.170.195.158
  s=Asterisk PBX 1.8.11.0
  c=IN IP4 81.170.XXX.XXX
  t=0 0
  m=audio 10060 RTP/AVP 18 3 0 8 101
  a=rtpmap:18 G729/8000
  a=fmtp:18 annexb=no
  a=rtpmap:3 GSM/8000
  a=rtpmap:0 PCMU/8000
  a=rtpmap:8 PCMA/8000
  a=rtpmap:101 telephone-event/8000
  a=fmtp:101 0-16
  a=silenceSupp:off - - - -
  a=ptime:20
  a=sendrecv
  
  ---
  
  &lt;--- SIP read from UDP:77.240.208.105:5060 ---&gt;
  SIP/2.0 100 Trying
  User-Agent: Centile-Supra/1
  CSeq: 102 INVITE
  Via: SIP/2.0/UDP 81.170.XXX.XXX:5060;branch=z9hG4bK4db8a605
  Content-Length: 0
  From: "0700XXXXXX" &lt;sip:55500XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net&gt;;tag=as5eaad2ef
  To: &lt;sip:0700XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net&gt;
  Call-ID: 498e8f9616aadc0a658b301909fe58d7@bahnhof-lda.soho1.voip.bahnhof.net
  
  &lt;-------------&gt;
  --- (8 headers 0 lines) ---
  
  &lt;--- SIP read from UDP:77.240.208.105:5060 ---&gt;
  SIP/2.0 404 No domain-name found in requestURI:0700XXXXXX
  User-Agent: Intraswitch/7.5.6.4.SR4-SNAPSHOT_SCF-8
  CSeq: 102 INVITE
  Via: SIP/2.0/UDP 81.170.XXX.XXX:5060;branch=z9hG4bK4db8a605
  Content-Length: 0
  Record-Route: &lt;sip:77.240.208.105;lr&gt;
  From: "0700XXXXXX" &lt;sip:55500XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net&gt;;tag=as5eaad2ef
  To: &lt;sip:0700XXXXXX@bahnhof-lda.soho1.voip.bahnhof.net&gt;;tag=e67fec39-f749-59b4-4b8f-c798e694a64b
  Supported: replaces, 100rel, timer
  Server: Intraswitch/7.5.6.4.SR4-SNAPSHOT_SCF-8
  Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, MESSAGE, PRACK, REFER, INFO, SUBSCRIBE, NOTIFY
  Contact: &lt;sip:0700XXXXXX@77.240.208.19:5061&gt;
  Call-ID: 498e8f9616aadc0a658b301909fe58d7@bahnhof-lda.soho1.voip.bahnhof.net
  </code></pre>
  
  <p>The obvious error is "SIP/2.0 404 No domain-name found in requestURI:0700XXXXXX", however the underlying condition causing this is not at all obvious to me :]</p>
  
  <p>Note, all XXX's are real values masked for obvious reasons.</p>
  
  <p>Any help or ideas to try is greatly appreciated!</p>
  
  <p><strong>SOLVED - UPDATE 2013-10-19</strong></p>
  
  <p>The issue is now solved, the operator Bahnhof (in Sweden) has a similar setup to Sipgate. This means there is very little flexibility in how you configure the REGISTER and Trunk. A small mistake here which would not affect the general SIP provider has major impact here, perhaps this is a high security strategy from Bahnhof and Sipgate. In short having a bad register will prevent you from making outbound calls.</p>
  
  <p>It came down to this in sip.conf,</p>
  
  <pre><code>Bad register: register =&gt; 55500XXXXXX:mypassword@bahnhof/2000
  OK  register: register =&gt; 55500XXXXXX:mypassword@bahnhof/55500XXXXXX
  </code></pre>
  
  <p>Then in extensions.conf,</p>
  
  <pre><code>[default]
  exten =&gt; 55500XXXXXX,1,Goto(010XXXXXXX-in,s,1)
  </code></pre>
  
  <p>Now outbound calls work, however here is where Bahnhof is acutally even more tricky then Sipgate, Bahnhof has a cluster of SIP servers where a inbound call can originate from any of them. When Asterisk resolves bahnhof-lda.soho1.voip.bahnhof.net it simply takes the first ip address and considers this the SIP peer. The problem is that a inbound SIP call can come from any of the six addresses and not only the address you registered at.</p>
  
  <p>The solution would be to add [bahnhof-peer-01], [bahnhof-peer-2] ... entries for each ip address,</p>
  
  <pre><code>[bahnhof-peer-01]
  type=peer
  context=default
  host=77.240.208.19
  insecure=port,invite
  canreinvite=no
  dtmfmode=rfc2833
  
  [bahnhof-peer-02]
  type=peer
  context=default
  host=77.240.208.20
  insecure=port,invite
  canreinvite=no
  dtmfmode=rfc2833
  
  ...
  </code></pre>
  
  <p><strong>OR</strong></p>
  
  <p>Simply set in sip.conf,</p>
  
  <pre><code>[general]
  context=default
  allowguest=yes
  alwaysauthreject=yes
  </code></pre>
  
  <p>extensions.conf,</p>
  
  <pre><code>[default]
  ; Incoming calls on SE line 010XXXXXXX (steered from "register" section)
  exten =&gt; 55500XXXXXX,1,Goto(010XXXXXXX-in,s,1)
  ; NOTHING MORE UNDER default
  
  [extensions]
  ...
  </code></pre>
  
  <p>This would allow any incoming calls to be accepted, even unauthenticated ones. One might see this as a security risk but I have all VoIP traffic tightly locked down by firewall rules so this is the solution I went with. Also, as long as you have the context set to default in [general] and you have a proper setup with nothing under the [default] context except the inbound extension you will be fine. Anonymous inbound calls will have no access to you trunks or extensions, only access to inbound extensions which they obviously will need to know (55500XXXXXX) to get through to your inbound rules for your Bahnhof number.</p>
  
  <p>So finally, this solution enabled both outbound and inbound calls via the Bahnhof SIP provider. Technically what seems to happen when you use the username as the extension on the register line is that this forces a Digest Auth towards the SIP server when an outbound call is made. This in turn seems to satisfy the SIP server with the domain-name part in the URI. This is not completely clear to me in relevance but obviously plays a part.</p>