Redirect calls by country

how can i redirect the incoming calls on my SIP trunk according to the source ip?? i need to filter the incoming calls by the source country…any idea?

In most cases you can’t because:

  1. IP address tends to reflect the home country of the organisation not the the actual country of origin;
  2. Most SIP provides operate back to back user agents and don’t pass through information on the true origin;
  3. If you have a SIP trunk, it will go to one place, which, for most people is the break in point from the PSTN (physically there may be multiple break in points, but then item (2) comes into play.

In the unlikely event that there is useful information in the SIP headers, you can use various functions beginning with SIP to recover the raw headers.

In practice though, for a break in from the PSTN, you are going to have better luck decoding the CLID as a phone number.