[Asterisk-Users] Asterisk confused when interface has multiple addresses?

Simon J Mudd sjmudd at pobox.com
Sat Jun 14 10:13:32 MST 2003


I have asterisk configured on a machine connected to Internet by a cable
modem with a public ip. The same network card has a private lan address
which I'm trying to use to play with an asterisk configuration with X-lite
or an softip phone.

sip.conf has bindaddr=192.168.0.1 [the private address of the LAN] to
which the client [192.168.0.2] is connected.

Doing a tcpdump on the register requests from X-lite I notice that * is
providing contact information and giving the public ip address.

See the original tcpdump.out at www.wl0.org/simon.mudd/tcp_dump.out
and the first commented packets below:

S: configured with eth0:1 192.168.0.1 (and eth0 as 24.132.244.120)
C: 192.168.0.2

Client sends REGISTER REQUEST

18:31:37.196309 192.168.0.2.1026 > 192.168.0.1.5060:  udp 314
REGISTER sip:domain.es SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2:5060
From: 912345678 <sip:912345678 at domain.es>
To: 912345678 <sip:912345678 at domain.es>
Contact: 912345678 <sip:912345678 at 192.168.0.2:5060>
Call-ID: 55DBE0F7A94841E5B2170D8BC3A35CAB at domain.es
CSeq: 20739 REGISTER
Expires: 500
Content-Length: 0

Asterisk sends Trying but mentions it's public ip address in the
contact field (is this normal? sip.conf has bindaddr = 192.168.0.1)

18:31:37.198137 192.168.0.1.5060 > 192.168.0.2.5060:  udp 317 (DF)
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.0.2:5060
From: 912345678 <sip:912345678 at domain.es>
To: 912345678 <sip:912345678 at domain.es>;tag=as46e87ccd
Call-ID: 55DBE0F7A94841E5B2170D8BC3A35CAB at domain.es
CSeq: 20739 REGISTER
User-Agent: Asterisk.PBX
Contact: <sip:912345678 at 24.132.244.120>
Content-Length: 0

Asterisk sends OK, again providing a public ip for the contact field

18:31:37.198511 192.168.0.1.5060 > 192.168.0.2.5060:  udp 376 (DF)
SIP/2.0 200 OK
Via: SIP/2.0/UDP.192.168.0.2:5060
From: 912345678 <sip:912345678 at domain.es>
To: 912345678 <sip:912345678 at domain.es>;tag=as46e87ccd
Call-ID: 55DBE0F7A94841E5B2170D8BC3A35CAB at domain.es
CSeq: 20739 REGISTER
User-Agent: Asterisk PBX
Expires: 500
Contact: <sip:912345678 at 24.132.244.120>;expires=500
Date: Sat, 14 Jun 2003 16:31:37 GMT
Content-Length: 0

The client hasn't recognised the ok, so sends a register again

18:31:39.200044 192.168.0.2.1026 > 192.168.0.1.5060:  udp 314
REGISTER sip:domain.es SIP/2.0
Via: SIP/2.0/UDP 192.168.0.2:5060
From: 912345678 <sip:912345678 at domain.es>
To: 912345678 <sip:912345678 at domain.es>
Contact: 912345678 <sip:912345678 at 192.168.0.2:5060>
Call-ID:.55DBE0F7A94841E5B2170D8BC3A35CAB at domain.es
CSeq: 20739 REGISTER
Expires: 500
Content-Length: 0

I have a minimal sip.conf with 
;
; SIP Configuration for Asterisk
;
[general]
port = 5060			; Port to bind to
bindaddr = 192.168.0.1		; Address to bind to TEMPORARILY
context = sip			; Default for incoming calls
transfer = yes
threewaycalling = yes
usecallerid = yes
hidecallerid = no
allow = all			; add this

[912345678]
type=friend
callerid="sip" <912345678>
host=dynamic
dtmfmode=inband
username=912345678
;secret=somesecret
accountcode=sip

and extensions.conf says:
;
; Static extension configuration files, used by
; the pbx_config module.
;
; The "General" category is for certain variables.  
;
[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified.  Remember that all comments
; made in the file will be lost when that happens. 
;
; XXX Not yet implemented XXX
;
static=yes
;
; if static=yes and writeprotect=no, you can save dialplan by
; CLI command 'save dialplan' too
;
writeprotect=no

;
; The "Globals" category contains global variables that can be referenced
; in the dialplan with ${VARIABLE} or ${ENV(VARIABLE)} for Environmental variable
; ${${VARIABLE}} or ${text${VARIABLE}} or any hybrid
;
[globals]
CONSOLE=Console/dsp				; Console interface for demo
IAXINFO=guest					; IAXtel username/password
TRUNK=Zap/g2					; Trunk interface

; ----------------------------------------------------------------------
[default]

include => local

; ----------------------------------------------------------------------
;
; We start with what to do when a call first comes in.
;
[demo]
exten => s,1,Wait,1                     ; Wait a second, just for fun
exten => s,2,Answer                     ; Answer the line
exten => s,3,DigitTimeout,5             ; Set Digit Timeout to 5 seconds
exten => s,4,ResponseTimeout,30         ; Set Response Timeout to 10 seconds
exten => s,5,BackGround(demo-congrats)  ; Play a congratulatory message
exten => s,6,BackGround(demo-instruct)  ; Play some instructions

exten => 2,1,BackGround(demo-moreinfo)  ; Give some more information.
exten => 2,2,Goto(s,6)

; doesn't seem to work(in French) maybe I don't have the sound support
exten => 3,1,SetLanguage(fr)            ; Set language to french
exten => 3,2,Goto(s,5)                  ; Start with the congratulations
exten => 4,1,Goto(local,s,1)            ; Go back to local

;
; # for when they're done with the demo
;
exten => #,1,Playback(demo-thanks)      ; "Thanks for trying the demo"
exten => #,2,Hangup                     ; Hang them up.

;
; A timeout and "invalid extension rule"
;
exten => t,1,Playback(demo-thanks)      ; "Thanks for trying the demo"
exten => t,2,Hangup                     ; Hang them up.
exten => i,1,Playback(invalid)          ; "That's not valid, try again"

; ----------------------------------------------------------------------
[local]

exten => 1000,1,Goto(demo,s,1)
exten => 1001,1,dial(SIP/912345678)		; Simon X-Lite

;
; A timeout and "invalid extension rule"
;
exten => t,1,Playback(demo-thanks)      ; "Thanks for trying the demo"
exten => t,2,Hangup                     ; Hang them up.
exten => i,1,Playback(invalid)          ; "That's not valid, try again"
exten => i,2,Hangup                     ; a bit drastic but thang them up!

include => sip

[fwd]
exten => _9.,1,Dial(SIP/${EXTEN-1}@fwd.pulver.com,tr)

[sip]
exten => 9999,1,Dial(SIP/912345678)

include => local


If the fact that * is providing a different IP address as contact
information correct, inspite of the bindaddr I've specified in sip.conf?

For the moment I see the SIP client ignores the replies, although * logs
the client as registered.

Confused?

Simon




More information about the asterisk-users mailing list