AsteriskThailand
May 23, 2012, 06:55:02 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: SIP กับปัญหา NAT  (Read 2304 times)
Patrickz
Global Moderator
Sr. Member
*****
Posts: 274


View Profile WWW
« on: October 24, 2007, 10:18:08 PM »

สวัสดีครับ  วันก่อนผมมีปัญหาเกี่ยวกับ one way audio ซึ่งดูเหมือนว่าเป็นปัญหายอดฮิตเสียจริงๆ  และก็พบว่าต้นเหตุนั้นมาจากเรื่อง NAT นั่นเอง

ผมมีข้อสงสัยว่าปัจจุบัน Asterisk ยังมีปัญหาเรื่อง NAT อยู่หรือเปล่าครับ?
เนื่องจากมีการแนะนำให้ใช้ nat=yes

อ้างอิงจาก
http://www.voip-info.org/wiki-Asterisk+sip+nat
Quote
If you set nat=yes for a client ( SIP UA ) that is BEHIND a NAT, Network address translator, device, Asterisk will somehow change the behaviour, adressing etc, of communication with the UA to make communication possible. What really happens is not very well documented, except in the source code (maybe...).

http://www.freepbx.org/support/documentation/administration-guide/adding-extensions
Quote
nat: yes or never. SIP is a nat-unfriendly protocol in that it specifies the return IP address for the call audio stream deep inside a packet. NAT works by rewriting packet source and destination IP addresses, but doesn't understand SIP (unless a good SIP Application Layer Gateway is installed). NAT is therefore problem if both the phone and the server PBX are separated from the public internet by different NATs (e.g. a home router and and corporate one.) In such a situation, audio won't work, but signaling will (phones will ring but no audio). To support remote home users behind conventional NATs, use yes, and either give the server PBX a public IP address or do a 1:1 IP mapping from a public IP to it's internal, then set IP_nat.conf to the public IP address of the system. NAT=yes instructs Asterisk to send audio to the IP it receives it from, regardless of what the SIP SDP says, and lets you have at least one NAT present and still have effective audio. Note that NATs vary widely as to how long they stay 'open'. Best practice when using Non-STUN phones is to have SIP registration expire every 60 seconds – the re-registration (outbound, by the phone) will keep the NAT open to receive calls. NAT=yes doesn't hurt anything when the client device is on the same LAN.

สรุปได้ว่า ปัญหาเรื่อง NAT เราสามารถแก้ปัญหาโดยเลือกใช้วิธี -
1. กำหนด nat=yes
2. ใช้ STUN

ผมเข้าใจถูกต้องไหมครับ?
ระหว่าง NAT=yes และ STUN แตกต่างกันอย่างไร มีข้อดีข้อเสียอย่างไรครับ?
Logged

iamoat
Newbie
*
Posts: 5


View Profile
« Reply #1 on: December 06, 2007, 11:35:54 PM »

ผมก็มีปัญหาเหมือนกันครับ

ยิ่งเวลาวาง Asterisk ไว้หลัง NAT ตัวที่หนึ่ง แล้ว SIP phone อยู่หลัง NAT อีกตัว
[Asterisk] <----> NAT1 <----> INTERNET <----> NAT2 <----> SIP PHONE

ใช้ STUN ก็แล้ว set nat=yes ก็แล้ว ปรากฏว่าระบบทำงานได้บ้างไม่ได้บ้าง

ลอง RTP debug ดูก็พบว่า packets มันส่งไปถูก address บ้าง ไม่ถูกบ้างสุดยากที่จะคาดเดา
อ่านมาหลาย web เขาบอกว่า config แบบนี้ไม่แนะนำให้ทำถ้าเป็นไปได้ให้หลีกเลี่ยง
ถ้ามีใครทำแล้ว work ช่วยบอกด้วยนะครับ
Logged

- Nattapong Mongkolnavin
W: http://www.octagon.co.th
jane
Newbie
*
Posts: 43


View Profile
« Reply #2 on: December 07, 2007, 11:34:04 PM »

SIP มีปัญหากับ NAT ครับ ไม่ใช่ Asterisk

วิธีแก้จริงๆ คือ ห้ามใช้ NAT หรือใช้ IPv6 ได้ก็ดี
วิทีเลี่ยงๆ ก็ตามที่คนอื่นๆ ตอบกัน

อีกวิธีก็ IAX2 ครับ รองรับ NAT
Logged
Patrickz
Global Moderator
Sr. Member
*****
Posts: 274


View Profile WWW
« Reply #3 on: December 10, 2007, 05:29:08 AM »

Quote
SIP มีปัญหากับ NAT ครับ ไม่ใช่ Asterisk
ขอบคุณครับ เป็น SIP ที่มีปัญหากับ NAT จริงๆ

อย่างนี้ลำบากหน่อย ถ้าผมเข้าใจไม่ผิด Media Gateway อย่าง cisco นั้นชอบ SIP มากกว่า และไม่ได้ support IAX ซะด้วย
Logged

jane
Newbie
*
Posts: 43


View Profile
« Reply #4 on: December 11, 2007, 12:39:16 AM »

Quote
SIP มีปัญหากับ NAT ครับ ไม่ใช่ Asterisk
ขอบคุณครับ เป็น SIP ที่มีปัญหากับ NAT จริงๆ

อย่างนี้ลำบากหน่อย ถ้าผมเข้าใจไม่ผิด Media Gateway อย่าง cisco นั้นชอบ SIP มากกว่า และไม่ได้ support IAX ซะด้วย


อย่างนั้นก็เทคนิค stun เลี่ยงๆ ไปก่อนครับ

ไม่กลอง setup IPv6 มาเทสดู  แต่เอง Asterisk support IPv6 หรือเปล่าก็ไม่รู้
Logged
Patrickz
Global Moderator
Sr. Member
*****
Posts: 274


View Profile WWW
« Reply #5 on: January 02, 2008, 03:39:45 PM »

เจอมาจาก asterisk forum

Quote
context=default
allowoverlap=no
bindport=5060
bindaddr=0.0.0.0
srvlookup=yes
externip=xxx.xxx.xxx.xxx
nat=yes
localnet=yyy.yyy.yyy.yyy/255.255.255.0

xxx คือ IP ภายนอก ( IP ของ gateway)
yyy คือ IP ภายใน


ที่มา: http://forums.digium.com/viewtopic.php?t=19559
Logged

jane
Newbie
*
Posts: 43


View Profile
« Reply #6 on: February 14, 2008, 12:27:27 AM »

ใช้ exterhost แทน exterip ถ้าเป็น dynamic dns
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
SEM | Asterisk | สถานที่ท่องเที่ยว | สัมมนา SEM