[asterisk-users] Asterisk both behind a NAT and outside at the
same time
Brad Templeton
brad+aster at templetons.com
Tue Oct 31 22:12:59 MST 2006
On Wed, Nov 01, 2006 at 08:10:29AM +0800, Leo Ann Boon wrote:
> Brad Templeton wrote:
> >
> The way I understand it, externalip and localnet work hand-in-hand. I do
> agree with you that this is commonly used for Asterisk behind a NAT. I
> believe these parameter just helps asterisk determine what to do. In
> your case, you don't lose anything - the external IP would still have to
> be written into every outbound packet.
It's called externip I think, not externalip. I have set both externip
to be my external IP address, and localnet to be the natwork, and even
set canreinvite=no and nat=yes and the SDP I get back from an invite to
extension at myasteriskexternal still has 192.186.* in it.
>
> >It uses bindaddr=0.0.0.0 and listens to both addresses.
> >
> externalip doesn't affect the bindaddr.
Would not expect it to. Just trying to be clear to people that
the machine has two ethernets. I was hoping Asterisk would
just automatically say, "Wait a minute, I'm taking an SDP with
addresses in the localnet, and sending it out to a peer on the
outside internet. That's not going to work!"
Now one of my tests has a SIP program I have written attempt to
call Asterisk. It sits on port 5061 invites to Asterisk on 5160
of the machine with the external address as follows:
INVITE sip:28 at truemain.templetons.com:5160;transport=udp SIP/2.0^M
Call-ID: 5d06b101b66fbcfaf09af61c794d8f04 at 198.144.201.82^M
CSeq: 1 INVITE^M
From: "Voxable" <sip:elided at sip1.telcommone.net>;tag=3445^M
To: "Party Leg1" <sip:28 at truemain.templetons.com:5160>^M
Via: SIP/2.0/UDP 198.144.201.82:5061;branch=z9hG4bK6563eba5fd430b5af93579617a44450e^M
Max-Forwards: 12^M
Contact: "Caller App" <sip:capp at 198.144.201.82:5061>^M
Date: Wed, 01 Nov 2006 04:52:07 GMT^M
User-Agent: Voxable 0.1^M
Content-Type: application/sdp^M
Content-Length: 154^M
^M
v=0
o=capp 1162356727 1 IN IP4 198.144.201.82
s=CApp3PCC
c=IN IP4 198.144.201.82
t=0 0
m=audio 5308 RTP/AVP 0 8
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PMCA/8000
Asterisk sends this on to the phone, but rewrites the SDP
to present a local one:
o=root 26391 26391 IN IP4 192.168.123.10
s=session
c=IN IP4 192.168.123.10
t=0 0
m=audio 10856 RTP/AVP 0 97 8 101
I answer the phone and it responds to this SDP with an OK
o=brad 8000 8000 IN IP4 192.168.123.18
s=SIP Call
c=IN IP4 192.168.123.18
t=0 0
m=audio 5004 RTP/AVP 0 101
a=sendrecv
a=rtpmap:0 PCMU/8000
a=ptime:20
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-11
Asterisk then sends back this SDP without rewriting it.
Is it only doing that because it knows the traffic came from
the same machine?
Asterisk forwards this OK back. Note the SDP
SIP/2.0 200 OK^M
Via: SIP/2.0/UDP 198.144.201.82:5061;branch=z9hG4bK94e379b15dbd22f8594fa6e88a4cfcc0;received=198.144.201.82^M
From: "Voxable" <sip:elided at sip1.telcommone.net>;tag=3445^M
To: "Party Leg1" <sip:28 at truemain.templetons.com:5160>;tag=as62de8d32^M
Call-ID: 5d06b101b66fbcfaf09af61c794d8f04 at 198.144.201.82^M
CSeq: 1 INVITE^M
User-Agent: Caller Asterisk^M
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY^M
Supported: replaces^M
Contact: <sip:28 at 198.144.201.82:5160>^M
Content-Type: application/sdp^M
Content-Length: 199^M
^M
v=0^M
o=root 26391 26391 IN IP4 192.168.123.18^M
s=session^M
c=IN IP4 192.168.123.18^M
t=0 0^M
m=audio 5004 RTP/AVP 0 8^M
a=rtpmap:0 PCMU/8000^M
a=rtpmap:8 PCMA/8000^M
a=silenceSupp:off - - - -^M
a=sendrecv^M
My software then forwards that SDP on to an outside location, where the
SDP is useless.
It works if the outside provider I forward the SDP to has my asterisk
box set with some flags (nat=yes I presume?) though I can't figure why.
That box is presumably, seeing the internal address, routing the
audio to some port on the * box, and asterisk is forwarding it but I
can't see how this is happening. Odd.
More information about the asterisk-users
mailing list