title: Kamailio overwrite From domain
body: <p>I'm using Kamailio 4.4. I need to overwrite call information: From header domain.
  sip.twilio.com to pstn.mycompany.io. Example:</p>
  
  <pre><code>From: "+16501112222" &lt;sip:+16501112222@sip.twilio.com&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>From: "+16501112222" &lt;sip:+16501112222@pstn.mycompany.io&gt;
  </code></pre>
  
  <p><strong>Call flow:</strong></p>
  
  <pre><code>Twilio (SP1) --&gt; MyCompany --&gt; SP2
  Twilio SIP -&gt; Calls: sip:14081112222@sip.mycompany.io -&gt; Kamailio -&gt; Kamailio look up table and convert sip:14081112222@sip.mycompany.io to sip:jdoe@sp2.com using dbaliases to send call to SP2. 
  </code></pre>
  
  <p>Client in <strong>SP2</strong> sees the call coming from Twilio. In order to redirect SIP Call to <strong>SP2</strong>, Kamailio performs a DNS lookup. I tried the following luck, although I see this code being executed. Using Kamailio default call script.</p>
  
  <pre><code>branch_route[MANAGE_BRANCH] {
  
          if($fd=~"sip\.twilio\.com") {
             xlog("L_INFO","|Masking Twilio call from: $fu");
             $fd = "pstn.mycompany.io"; 
  
          }
  
          xdbg("new branch [$T_branch_idx] to: $ru from: $fu\n");
          route(NATMANAGE);
  }
  </code></pre>
  
  <p>Related:
  <a href="https://stackoverflow.com/questions/41477060/twilio-overwrite-callerid-with-sip-calls">Twilio overwrite callerId with SIP calls</a></p>