Set per PEER source IP or PORT

Hi all,
i’m struggling with this issue, not caused by asterisk, but i need a solution/workaround.

ASTERISK 1.6 (or 1.8, i can do an upgrade)

  • sip peer A
  • sip peer B

i’m registerign to a (FCKNG) gateway that does not accept two differen users registering from the same source [ip:port]

is there a way to set the source port and/or source ip at peer level?
(the idea :bulb: is that i could add aliases to the eth interface and use them as source ips)

any idea?

thanks in advice.

Howdy,

You should be able to accomplish that in Asterisk 12 with chan_pjsip, but you won’t be able to do it in any prior version or with chan_sip.

Cheers

thank you for the hint!
i downloaded/compiled/installed everything (pjproject - asterisk-12.0.0)… OK!

i configured pjsip.conf as follows

[mytrunk]
type=registration
transport=transport-udp           ;configured as default
outbound_auth=mytrunk_auth
server_uri=sip:192.168.1.254:5062              ;server IP - dst POST
client_uri=sip:utente@192.168.1.211:5061   ;asterisk IP - source PORT
contact_user=utente
retry_interval=30
forbidden_retry_interval=600
expiration=3600

[mytrunk_auth]
type=auth
auth_type=userpass
password=*********
username=utente
realm=192.168.1.254

in asterisk CLI i can see the registration from port 5061 to port 5062 but tcpdump says something different: destination port is 5062 but src is always 5060
i’ll try if the GATEWAY will accept such registrations…

res_pjsip_outbound_registration.c:401 schedule_retry: No response received from 'sip:192.168.1.254:5062' on registration attempt to 'sip:utente@192.168.1.211:5061', retrying in '30'
[Jan 17 15:05:59] WARNING[27064]: res_pjsip_outbound_registration.c:401 schedule_retry: No response received from 'sip:192.168.1.254:5062' on registration attempt to 'sip:utente@192.168.1.211:5061', retrying in '30'

tcpdump output

15:13:12.717025 IP 192.168.1.221.5060 > 192.168.1.254.5062: SIP, length: 503
15:13:43.212236 IP 192.168.1.221.5060 > 192.168.1.254.5062: SIP, length: 503
15:13:43.713228 IP 192.168.1.221.5060 > 192.168.1.254.5062: SIP, length: 503
15:13:44.712862 IP 192.168.1.221.5060 > 192.168.1.254.5062: SIP, length: 503
15:13:46.713477 IP 192.168.1.221.5060 > 192.168.1.254.5062: SIP, length: 503

same story if i try to change the src IP

now let’s see if what the (FCKNG) gateway thinks about it :smile:

No, the gateway (aka Cisco Call Manager) does not like multiple registrations coming from the same IP address.

so:
i have aliases on my eth0
eth0:1 x.y.x.1
eth0:2 x.y.x.2
eth0:n x.y.x.n

is it possible to make
sip:user 1 register from eth0:1
sip:user 2 register from eth0:2
sip:user n register from eth0:n
?

thank you.

Howdy,

If you have different peers and want different addresses for each, assuming your system has more than one address associated to it, then you’d create one transport for each address and associate the requisite transport with the endpoint you want.

thank you very much!

after configuring the following 3 transport sections i see packets coming from the different aliases of my asterisk box: GREAT!

[transport-1]
type=transport
protocol=udp
bind=10.0.0.1 ;alias0

[transport-2]
type=transport
protocol=udp
bind=10.0.0.2 ;alias1

[transport-3]
type=transport
protocol=udp
bind=10.0.0.3 ;alias2

now i’m confused about wich type of registration i need:
i need to simulate 3 different phones that register to a sip-server.

  1. is it correct to create 3 “type=registration” like the foolowing?
  2. how to manage incoming calls in extensions.conf (context/extension)?
  3. how to manage outgoing calls in extensions.conf (dial command)?
[phoneA]
type=registration
transport=transport-1
outbound_auth=phoneA_auth
server_uri=sip:server-ip:5060
client_uri=sip:phoneA@server-ip:5060
contact_user=phoneA
retry_interval=30
forbidden_retry_interval=30
expiration=3600

[phoneA_auth]
type=auth
auth_type=userpass
password=phoneA
username=phoneA
realm=server-ip