Set source IP in outgoing calls

Hi All,

I am using asterisk 13.3.2 and pjproject 2.4.
On asterisk cli I am executing

channel originate pjsip/timbrazo/sip:70710024@172.18.21.6 extension 100@timbrazo

my pjchan.conf

[timbrazo]
type = endpoint
aors = timbrazo

[timbrazo]
type = identify
endpoint = timbrazo
match = 172.18.21.6

[timbrazo]
type = aor
contact=sip:172.18.21.231:5060

my extensions.conf

[timbrazo] exten => s,1,Wait(2) exten => s,n,Hangup

my server has 2 IP addresses
eth0.110 172.18.21.229
eth1.110 172.18.21.231

when i execute the ‘channel outgoing’ command the INVITE is sent with 172.18.21.229 address.
how can i configure pjchan so that the INVITE is sent with 172.18.21.231 address ?

regards,
Martin

What is your COMPLETE pjsip.conf? What do you have for transports?

What you’ll likely need to do is set up multiple transports that bind explicitly to each IP address and then specify on the endpoint which transport to use. This will guarantee that the source address is what you want.

thanks for your reply, Jcolp.

here is my modifed pjsip.conf as per your suggestion.

[code][general]
debug=on

[transport-udp]
type=transport
protocol=udp
bind=172.18.21.229:5060

[transport-timbrazo-udp]
type=transport
protocol=udp
bind=172.18.21.231:5060

[anonymous]
type=endpoint
media_address=172.18.124.69
direct_media=yes
dtmf_mode=inband
context=default
inband_progress=yes
disallow=all
allow=ulaw
allow=alaw
transport=transport-udp

[timbrazo]
type=endpoint
transport=transport-timbrazo-udp[/code]

I called the cli command

but still the INVITE is sent over the eth0 interface (172.18.21.229)

pjsip list endpoints yields,

[code] Endpoint: <Endpoint/CID…> <State…> <Channels.>

Endpoint: anonymous In use 25 of inf
Endpoint: timbrazo Unknown 0 of inf
[/code]

is unknown the correct state?

What is the INVITE that is sent? It will be output if “pjsip set logger on” is on. Also please include the full console output.

Here are the INVITE headers

Via: SIP/2.0/UDP 172.18.21.229:5060;rport;branch=z9hG4bKPjf6cc97a0-0a4d-4c1a-8f9b-fc784781596e From: <sip:365e74f1-b8bd-4229-982a-64d493f0cc5d@172.18.21.231>;tag=7afa2487-30bd-40cd-8b42-df80b602eac4 To: <sip:70710024@172.18.21.4> Contact: <sip:365e74f1-b8bd-4229-982a-64d493f0cc5d@172.18.21.229:5060> Call-ID: 3fe1852f-e0d9-49c7-bc25-c786804e2967 CSeq: 11683 INVITE Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REGISTER, REFER Supported: 100rel, timer, replaces, norefersub Session-Expires: 1800 Min-SE: 90 Max-Forwards: 70 User-Agent: Asterisk PBX 13.3.2 Content-Type: application/sdp Content-Length: 68

though the INVITE is sent over the 172.18.21.231 interface, I notice

in the header.

Also the From is not set correctly

btw. I have lots of traffic so I can’t capture the console output

here is the complete INVITE

Request-Line: INVITE sip:70710024@172.18.21.4 SIP/2.0 Method: INVITE Request-URI: sip:70710024@172.18.21.4 [Resent Packet: False] Message Header Via: SIP/2.0/UDP 172.18.21.229:5060;rport;branch=z9hG4bKPjf6cc97a0-0a4d-4c1a-8f9b-fc784781596e From: <sip:365e74f1-b8bd-4229-982a-64d493f0cc5d@172.18.21.231>;tag=7afa2487-30bd-40cd-8b42-df80b602eac4 To: <sip:70710024@172.18.21.4> Contact: <sip:365e74f1-b8bd-4229-982a-64d493f0cc5d@172.18.21.229:5060> Call-ID: 3fe1852f-e0d9-49c7-bc25-c786804e2967 CSeq: 11683 INVITE Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REGISTER, REFER Supported: 100rel, timer, replaces, norefersub Session-Expires: 1800 Min-SE: 90 Max-Forwards: 70 User-Agent: Asterisk PBX 13.3.2 Content-Type: application/sdp Content-Length: 68 Message Body Session Description Protocol Session Description Protocol Version (v): 0 Owner/Creator, Session Id (o): - 102667739 102667739 IN IP4 10.72.8.214 Session Name (s): Asterisk Time Description, active time (t): 0 0

i just enabled, in the logger.conf file, the verbose and debug options

and looking for the destination number in the /var/log/asterisk/messages and I couldnt file any logs regarding this outbound call attempt.

actually, i just found out console says

Any ideas on this one? anyone?

No further ideas, but I do believe it is in use by others. I’d suggest filing an issue[1] with the complete configuration, network topology/configuration, and packet traces. That’s the only way to determine what is going on.

[1] issues.asterisk.org/jira

Using AMI interface it works fine.

AMI Action

Action: Originate Channel: PJSIP/timbrazo/sip:70710024@172.18.21.4 Context: timbrazo Exten: 70710024 Priority: 1 Callerid: 70610161 Variable: __SIPADDHEADER=P-Asserted-Identity: <tel:70710024> Timeout: 15000 Async: yes ActionID: b4646a6465e546f

INVITE

INVITE sip:70710024@172.18.21.4 SIP/2.0 Via: SIP/2.0/UDP 172.18.21.229:5060;rport;branch=z9hG4bKPjaeee3cc4-c690-4bb3-891b-9b6b7ffe12d6 From: <sip:70610161@172.18.21.231>;tag=efceda3b-de5e-4018-9c02-88a5d9f3c58e To: <sip:70710024@172.18.21.4> Contact: <sip:e7eed757-1739-40ba-bcef-f1fcc97335fb@172.18.21.229:5060> Call-ID: 9393c3ba-3d9c-499b-82f0-ba6584b9b86c CSeq: 21410 INVITE Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REGISTER, REFER Supported: 100rel, timer, replaces, norefersub Session-Expires: 1800 Min-SE: 90 Max-Forwards: 70 User-Agent: Asterisk PBX 13.3.2 Content-Type: application/sdp Content-Length: 70

The problem now is that I cannot add the P-Asserted-Identity header. It seems like __SIPADDHEADER only works with chan_sip.

how do I add SIP headers in AMI with PJSIP ?

With chan_sip, the correct way of adding P-A-I is to use sendrpid=pai and set the caller ID. I suspect the case is similar for PJSIP.

ok, that was easy