SDP payload sets '127.0.0.1' instead of 'media_address'-Parameter

Hello everybody,
i have a problem setting the ‘media_address’-Parameter in ‘chan_pjsip’ endpoint object. Trying to assign the eth0-address to ‘media_address’ fails. Everytime in SDP payload i see ‘127.0.0.1’ in SDP parameters ‘o’ and ‘c’ (only if eth0-address and ‘media_address’ are equal). In case they differ, SDP parameters are modified. When i lookup the endpoint in cmd, then the set ‘media_address’ is shown.

The outgoing endpoint is connected local to a kamailio instance. Used asterisk version is 13.19.0.

What is the contents of “/etc/hosts”? What is your full configuration? As well if it is equal why are you setting it?

Content of ‘/etc/hosts’ is:
127.0.0.1 localhost
127.0.1.1 ast

::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

eth0 for example has: 10.1.1.100

I want to set ‘media_address’ to ‘10.1.1.100’, because in my configuration asterisk selects ‘127.0.0.1’ by default.

Topology:

kamailio (interface lo, Port 50000) <—> asterisk (interface any, Port 50001)

Asterisk registers to kamailio.

What is the hostname of your system? If you add an entry to /etc/hosts with the IP address and hostname and restart Asterisk does it then place the correct IP address into things?

No, it doesn´t take an effect.
The endpoint, which is registered to kamailio has such output:

=========================================================
100rel :yes
accountcode :
acl :
aggregate_mwi : true
allow : (alaw|ulaw)
allow_overlap : true
allow_subscribe : true
allow_transfer : true
aors : Ast1
asymmetric_rtp_codec : false
auth :
bind_rtp_to_media_address : false
call_group :
callerid :
callerid_privacy : allowed_not_screened
callerid_tag :
connected_line_method : invite
contact_acl :
context : from-external
cos_audio : 0
cos_video : 0
device_state_busy_at : 0
direct_media : false
direct_media_glare_mitigation : none
direct_media_method : invite
disable_direct_media_on_nat : false
dtls_ca_file :
dtls_ca_path :
dtls_cert_file :
dtls_cipher :
dtls_fingerprint : SHA-256
dtls_private_key :
dtls_rekey : 0
dtls_setup : active
dtls_verify : No
dtmf_mode : rfc4733
fax_detect : false
fax_detect_timeout : 0
force_avp : false
force_rport : true
from_domain :
from_user : Ast1
g726_non_standard : false
ice_support : false
identify_by : username,ip
inband_progress : false
incoming_mwi_mailbox :
language :
mailboxes :
media_address : 10.1.1.100
media_encryption : no
media_encryption_optimistic : false
media_use_received_transport: false
message_context :
moh_suggest : default
mwi_from_user :
mwi_subscribe_replaces_unsolicited : false
named_call_group :
named_pickup_group :
notify_early_inuse_ringing : false
one_touch_recording : false
outbound_auth : Ast1
outbound_proxy :
pickup_group :
record_off_feature : automixmon
record_on_feature : automixmon
refer_blind_progress : true
rewrite_contact : false
rpid_immediate : false
rtcp_mux : false
rtp_engine : asterisk
rtp_ipv6 : false
rtp_keepalive : 0
rtp_symmetric : false
rtp_timeout : 0
rtp_timeout_hold : 0
sdp_owner : -
sdp_session : asterisk
send_diversion : true
send_pai : false
send_rpid : false
set_var :
srtp_tag_32 : false
sub_min_expiry : 0
subscribe_context :
t38_udptl : false
t38_udptl_ec : none
t38_udptl_ipv6 : false
t38_udptl_maxdatagram : 0
t38_udptl_nat : false
timers : yes
timers_min_se : 90
timers_sess_expires : 1800
tone_zone :
tos_audio : 0
tos_video : 0
transport : udp-transport
trust_id_inbound : false
trust_id_outbound : false
use_avpf : false
use_ptime : false
user_eq_phone : false
voicemail_extension :

If i would choose another ip in ‘media_address’ parameter, for example 10.1.1.101, it will happen in SDP.

At startup Asterisk logs what it has determined its local IPv4 and IPv6 address to be. What does that show?

At startup logging dumps:

– Local IPv4 address determined to be: 10.1.1.100
– Local IPv6 address determined to be: fe80::a00:27ff:fe23:bb8a

Very interesting, can’t say I’ve seen anyone experience placing 127.0.0.1 into the SDP like that without media_address. I’d suggest filing an issue[1] with all available information.

[1] https://issues.asterisk.org/jira

Thanks for your help.

It figured out, that when i change column ‘ps_aors.contact’ from value ‘sip:127.0.0.1:63605’ to ‘sip:10.1.1.100:63605’ or ‘sip:10.1.1.100:63605’ it accepts for both cases ‘10.1.1.100’ in SDP.

Ah, that explains it. The code uses the interface address that the system tells it will be used to send the message. Since your message was going to 127.0.0.1 the system told it that it would be going out that interface, so it put 127.0.0.1 in the SDP.

Is this the wanted behavior? I test migration from ‘chan_sip’ to ‘chan_pjsip’. In ‘chan_sip’ the ‘media_address’ took effect there in the same scenario.

I think it is reasonable to expect media_address to work there, yes.