[Home]

Summary:ASTERISK-08581: Asterisk doesn't use externip if private IP is outside localnet
Reporter:kokoskarokoska (kokoskarokoska)Labels:
Date Opened:2007-01-15 10:59:22.000-0600Date Closed:2007-06-30 09:20:03
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) sip.conf
( 1) verbosedebug.txt
Description:Asterisk 1.4.0 ignores externip and use its local private IP (in contact header and in SDP too) if its own local IP is "outside" localnet setting.
Asterisk 1.2.4 works fine.

IP of Asterisk box 10.10.10.1

sip.conf:
externip = 1.2.3.4
localnet = 10.10.20.0/255.255.255.0

1.2.4 works, 1.4.0 doesn't
Comments:By: Joshua C. Colp (jcolp) 2007-01-15 12:46:33.000-0600

I was unable to reproduce this with the following settings:

IP of box = 192.168.2.2
externip = 198.164.30.2
localnet = 192.168.4.0/255.255.255.0

Can you please do the following:
1. Provide a sip debug of a call that fails
2. Provide sip.conf minus passwords

Thanks!

By: kokoskarokoska (kokoskarokoska) 2007-01-15 14:15:01.000-0600

Here is Sip debug (REGISTER and INVITE):

Bad registry to my VoIP TSP:

[Jan 15 20:43:40] NOTICE[25461]: chan_sip.c:7055 sip_reregister:    -- Re-registration for  226210124@226210124
REGISTER 13 headers, 0 lines
Reliably Transmitting (NAT) to 82.119.243.21:5060:
REGISTER sip:sip.netphone.cz SIP/2.0
Via: SIP/2.0/UDP 10.42.19.177:6090;branch=z9hG4bK67cbb5a7;rport
From: <sip:226210124@sip.netphone.cz>;tag=as1bcb5e11
To: <sip:226210124@sip.netphone.cz>
Call-ID: 449517bc7941de1e1fd1d6723aaacc61@sip.netphone.cz
CSeq: 104 REGISTER
User-Agent: e.com-pbx
Max-Forwards: 70
Authorization: Digest username="226210124", realm="sip.netphone.cz", algorithm=MD5, uri="sip:sip.netphone.cz", nonce="45abda2f922f232e9bd2429378a4e2e50661bd4d", response="cdf2090813ad7adef3e4e23be81ad019", opaque=""
Expires: 120
Contact: <sip:226210124@10.42.19.177:6090>
Event: registration
Content-Length: 0



Bad incoming call from local phone:


pbx3*CLI>
<--- SIP read from 10.42.19.177:6095 --->
INVITE sip:999@86.49.60.237:6090 SIP/2.0
Record-Route: <sip:86.49.60.237:6095;ftag=85926532566;lr=on>
Via: SIP/2.0/UDP 86.49.60.237:6095;branch=z9hG4bK7c13.a98121a.0
Via: SIP/2.0/UDP 192.168.1.101;received=213.220.193.148;rport=5060;branch=z9hG4bKc0a801650000003945abda7d0000218a0000004a
From: "unknown"<sip:2301@pbx.crs-net.cz:6095>;tag=85926532566
To: <sip:999@pbx.crs-net.cz:6095>
Contact: <sip:2301@213.220.193.148:5060>
Call-ID: FFF17B67-25C8-44AC-883D-2577BA691E03@192.168.1.101
CSeq: 2 INVITE
Max-Forwards: 69
User-Agent: SJphone/1.61.321a (SJ Labs)
Content-Length: 312
Content-Type: application/sdp

v=0
o=- 3377879293 3377879293 IN IP4 192.168.1.101
s=SJphone
c=IN IP4 192.168.1.101
t=0 0
a=setup:active
m=audio 49164 RTP/AVP 18 8 98 3 101
a=rtpmap:18 G729a/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:98 iLBC/8000
a=fmtp:98 mode=20
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11,16

<------------->
--- (13 headers 14 lines) ---
Sending to 10.42.19.177 : 6095 (NAT)
Using INVITE request as basis request - FFF17B67-25C8-44AC-883D-2577BA691E03@192.168.1.101
Found user '2301'
Found RTP audio format 18
Found RTP audio format 8
Found RTP audio format 98
Found RTP audio format 3
Found RTP audio format 101
Peer audio RTP is at port 192.168.1.101:49164
Found description format G729a for ID 18
Found description format PCMA for ID 8
Found description format iLBC for ID 98
Found description format GSM for ID 3
Found description format telephone-event for ID 101
Capabilities: us - 0x108 (alaw|g729), peer - audio=0x50a (gsm|alaw|g729|ilbc)/video=0x0 (nothing), combined - 0x108 (alaw|g729)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)
Peer audio RTP is at port 192.168.1.101:49164
Looking for 999 in openser.lines (domain 86.49.60.237)
list_route: hop: <sip:86.49.60.237:6095;ftag=85926532566;lr=on>

<--- Transmitting (NAT) to 10.42.19.177:6095 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 86.49.60.237:6095;branch=z9hG4bK7c13.a98121a.0;received=10.42.19.177
Via: SIP/2.0/UDP 192.168.1.101;received=213.220.193.148;rport=5060;branch=z9hG4bKc0a801650000003945abda7d0000218a0000004a
From: "unknown"<sip:2301@pbx.crs-net.cz:6095>;tag=85926532566
To: <sip:999@pbx.crs-net.cz:6095>
Call-ID: FFF17B67-25C8-44AC-883D-2577BA691E03@192.168.1.101
CSeq: 2 INVITE
User-Agent: e.com-pbx
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: <sip:999@10.42.19.177:6090>
Content-Length: 0


<------------>
Audio is at 10.42.19.177 port 20954
Adding codec 0x8 (alaw) to SDP
Adding codec 0x100 (g729) to SDP
Adding non-codec 0x1 (telephone-event) to SDP

<--- Reliably Transmitting (NAT) to 10.42.19.177:6095 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 86.49.60.237:6095;branch=z9hG4bK7c13.a98121a.0;received=10.42.19.177
Via: SIP/2.0/UDP 192.168.1.101;received=213.220.193.148;rport=5060;branch=z9hG4bKc0a801650000003945abda7d0000218a0000004a
Record-Route: <sip:86.49.60.237:6095;ftag=85926532566;lr=on>
From: "unknown"<sip:2301@pbx.crs-net.cz:6095>;tag=85926532566
To: <sip:999@pbx.crs-net.cz:6095>;tag=as6546a420
Call-ID: FFF17B67-25C8-44AC-883D-2577BA691E03@192.168.1.101
CSeq: 2 INVITE
User-Agent: e.com-pbx
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Contact: <sip:999@10.42.19.177:6090>
Content-Type: application/sdp
Content-Length: 287

v=0
o=root 20660 20660 IN IP4 10.42.19.177
s=session
c=IN IP4 10.42.19.177
t=0 0
m=audio 20954 RTP/AVP 8 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv





And here is my sip.conf:

[general]
context=in.guest
allowguest=yes
allowoverlap=no
;allowtransfer=no

realm=pbx.crs-net.cz

bindport=6090
bindaddr=0.0.0.0

srvlookup=yes

;domain=mydomain.tld


;pedantic=yes

tos_sip=cs3
tos_audio=ef
tos_video=af41

maxexpiry=600

minexpiry=60
defaultexpiry=120
t1min=100

;notifymimetype=text/plain
;checkmwi=10
;vmexten=voicemail


disallow=all
allow=alaw
allow=g729

mohinterpret=default

;language=en

;relaxdtmf=yes
;trustrpid = no
;sendrpid = yes
;progressinband=never


useragent=e.com-pbx
;promiscredir = no



;usereqphone = no

dtmfmode = rfc2833

;compactheaders = yes

;videosupport=yes
;maxcallbitrate=384

;callevents=no

;alwaysauthreject = yes

;g726nonstandard = yes

;regcontext=sipregistrations


;--------------------------- RTP timers ----------------------------------------------------
rtptimeout=10
rtpholdtimeout=60
;rtpkeepalive=<secs>

;--------------------------- SIP DEBUGGING ---------------------------------------------------
;sipdebug = yes
;recordhistory=yes
;dumphistory=yes

;--------------------------- STATUS NOTIFICATIONS (SUBSCRIPTIONS) ----------------------------
;allowsubscribe=no
;subscribecontext = default
;notifyringing = yes
;notifyhold = yes
;limitonpeers = yes

;----------------------------------------- T.38 FAX PASSTHROUGH SUPPORT -----------------------
; t38pt_udptl = yes


;----------------------------------------- OUTBOUND SIP REGISTRATIONS  ------------------------
register => 226210124:password@226210124/226210124
registertimeout=20
registerattempts=0

;----------------------------------------- NAT SUPPORT ------------------------
; The externip, externhost and localnet settings are used if you use Asterisk
; behind a NAT device to communicate with services on the outside.

externip=86.49.60.237
;externhost=pbx.crs-net.cz
;externrefresh=10

localnet=10.42.17.0/255.255.255.0
nat=yes

;----------------------------------- MEDIA HANDLING --------------------------------
canreinvite=no

;----------------------------------------- REALTIME SUPPORT ------------------------
;rtcachefriends=yes
;rtsavesysname=yes
;rtupdate=yes
;rtautoclear=yes
;ignoreregexpire=yes

;----------------------------------------- SIP DOMAIN SUPPORT ------------------------
;domain=mydomain.tld,mydomain-incoming
;domain=1.2.3.4
;allowexternalinvites=no
;autodomain=yes
;fromdomain=pbx.crs-net.cz

;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
; jbenable = yes
; jbforce = no
; jbmaxsize = 200
; jbresyncthreshold = 1000
; jbimpl = fixed
; jblog = no
;-----------------------------------------------------------------------------------

[authentication]
;auth=mark:topsecret@digium.com



; ------------------------------
[226210124]
type=friend
context=in.netphone
username=226210124
secret=password
fromuser=226210124
fromdomain=sip.netphone.cz
host=sip.netphone.cz
port=5060
canreinvite=no
nat=yes
qualify=no
insecure=port,invite
disallow=all
allow=alaw
allow=g729
allow=g726


[2301]
type=friend
context=openser.lines
username=2301
secret=password
host=86.49.60.237
port=6095
canreinvite=no
nat=yes
qualify=no
insecure=port,invite
disallow=all
allow=alaw
allow=g729
allow=g726
;------------------------------------------------------------------------------

By: kokoskarokoska (kokoskarokoska) 2007-01-21 16:20:43.000-0600

Should I provide some other info/debug/config to help with fixing this bug?

k.r.

By: Serge Vecher (serge-v) 2007-01-29 08:40:35.000-0600

please read the settings carefully: nat=yes is for situations when Asterisk is communicating with devices behind a nat -> your phone is on the same ip net as Asterisk, so nat should be no and externip should be used.

A configuration error, not a bug.

By: kokoskarokoska (kokoskarokoska) 2007-01-29 09:27:50.000-0600

No, no serge-v, you are completly wrong!

If you read sip debug carefully, you see that phone is on other net behind different NAT.
Please check IPs:
1. Asterisk: internal 10.42.19.177, external IP of router 86.49.60.237
1. Phone: internal 192.168.1.101, external IP of router 213.220.193.148

I hope it is clear. If not, tell me what should I explain.

Thanx a lot!
k.r.



By: Serge Vecher (serge-v) 2007-02-01 13:01:28.000-0600

gotcha, I didn't read it carefully enough. What's happening if you use 1.4 from svn? Also, it could be useful to see a log from a 1.2 release with the same config. Do the debug as per following:

1) Prepare test environment (reduce the amount of unrelated traffic on the server);
2) Make sure your logger.conf has the following line:
  console => notice,warning,error,debug
3) restart Asterisk with the following command:
  'asterisk -Tvvvvvdddddngc | tee /tmp/verbosedebug.txt'
4) Enable SIP transaction logging with the following CLI commands:
set debug 4
set verbose 4
sip debug
5) Trim startup information and attach verbosedebug.txt to the issue.


By: kokoskarokoska (kokoskarokoska) 2007-02-02 03:47:18.000-0600

:-)
I do it tomorow - install * from svn, catch debug and the same for 1.2.4.

Thanx a lot for your reply!
k.r.



By: kokoskarokoska (kokoskarokoska) 2007-02-20 16:53:40.000-0600

Today I installed SVN Trunk version (SVN-trunk-r55556M) and the behaviour is the same :-(

If Asterisk IP (10.42.20.205) is outside localnet setting (10.42.19.0/255.255.255.0) Asterisk doesn't use externip (86.49.60.237).
If I changed localnet settings to 10.42.20.0/255.255.255.0 Asterisk works fine, but it is not what I need...

Debug + sip.conf included.

Thanx all.
kokoska.rokoska

By: Joshua C. Colp (jcolp) 2007-02-20 17:12:59.000-0600

Fixed in 1.4 as of revision 55688 and trunk as of revision 55697.

By: Joshua C. Colp (jcolp) 2007-02-20 17:58:10.000-0600

Actually, the correct fix would be to add another localnet entry that just encompasses the IP address. If this still isn't acceptable I will have to add an option... since one person needs it one way, and you need it the other.

By: Olle Johansson (oej) 2007-02-22 04:04:18.000-0600

kokoskarokoska: If you want asterisk to ALWAYS use extern IP, then set localnet to a network you don't use at all.

By: kokoskarokoska (kokoskarokoska) 2007-02-22 04:51:15.000-0600

Thanx oej for your reply!
Id did it, but it doesn't work in 1.4 (but works in 1.2.4).
And all this thread is about this bug!

Regards,
kokoska.rokoska



By: kokoskarokoska (kokoskarokoska) 2007-03-05 18:41:16.000-0600

Now I have tried 1.4.1 and the bug still remains:
1. if Asterisk's IP is outside localnet settings => externip is never used
2. if Asterisk's IP is inside localnet setting = externip is not used to localnet including Asterisk machine itselves

The same bug is from 1.4.0 to SVN-trunk-r55556M and in 1.4.1 too.
SVN trunk version form 26.2.2007 works great. Tomorrow I reinstall it and post the correct svn trunk version number.

If you want some other info, please tell me it. I do what i can to help bring Asterisk 1.4 to production use :-)

Thanx!

kokoska.rokoska

!!UPDATE!! The only one working version is SVN-trunk-r55716M !!



By: Joshua C. Colp (jcolp) 2007-03-11 19:54:10

Added matchexterniplocally to 1.4 as of revision 58779 and trunk as of revision 58780. Now you can both decide how chan_sip handles it.