Asterisk Nat=force_rport,comedia With Routing

by ADMIN 46 views

Introduction

In this article, we will explore the configuration of Asterisk PBX to use nat=force_rport,comedia with routing. This setup is particularly useful when you have multiple subnetworks and want to establish connections between them without relying on real NAT (Network Address Translation). We will delve into the details of this configuration and provide a step-by-step guide on how to set it up.

Understanding the Setup

In our setup, we have two subnetworks: 10.4.0.0/24 and 10.1.0.0/24. The Asterisk PBX is located at 10.4.0.40, while Phone 1 is at 10.4.0.9 and Phone 2 is at 10.1.0.66. We will use routing between these subnetworks to establish connections between the phones and the PBX.

Configuring Asterisk

To configure Asterisk to use nat=force_rport,comedia with routing, we need to make the following changes to the sip.conf file:

[general]
bindport = 5060
bindaddr = 0.0.0.0
disallow = all
allow = ulaw
allow = alaw
allow = g729
allow = gsm
allow = g726
allow = g726-24
allow = g726-40
allow = g729
allow = h263
allow = h263-1998
allow = h263-1998-fld
allow = h263p
allow = h263p-fld
allow = h263p-1998
allow = h263p-1998-fld
allow = h263p-2000
allow = h263p-2000-fld
allow = h263p-2001
allow = h263p-2001-fld
allow = h263p-2002
allow = h263p-2002-fld
allow = h263p-2003
allow = h263p-2003-fld
allow = h263p-2004
allow = h263p-2004-fld
allow = h263p-2005
allow = h263p-2005-fld
allow = h263p-2006
allow = h263p-2006-fld
allow = h263p-2007
allow = h263p-2007-fld
allow = h263p-2008
allow = h263p-2008-fld
allow = h263p-2009
allow = h263p-2009-fld
allow = h263p-2010
allow = h263p-2010-fld
allow = h263p-2011
allow = h263p-2011-fld
allow = h263p-2012
allow = h263p-2012-fld
allow = h263p-2013
allow = h263p-2013-fld
allow = h263p-2014
allow = h263p-2014-fld
allow = h263p-2015
allow = h263p-2015-fld
allow = h263p-2016
allow = h263p-2016-fld
allow = h263p-2017
allow = h263p-2017-fld
allow = h263p-2018
allow = h263p-2018-fld
allow = h263p-2019
allow = h263p-2019-fld
allow = h263p-2020
allow = h263p-2020-fld
allow = h263p-2021
allow = h263p-2021-fld
allow = h263p-2022
allow = h263p-2022-fld
allow = h263p-2023
allow = h263p-2023-fld
allow = h263p-2024
allow = h263p-2024-fld
allow = h263p-2025
allow = h263p-2025-fld
allow = h263p-2026
allow = h263p-2026-fld
allow = h263p-2027
allow = h263p-2027-fld
allow = h263p-2028
allow = h263p-2028-fld
allow = h263p-2029
allow = h263p-2029-fld
allow = h263p-2030
allow = h263p-2030-fld
allow = h263p-2031
allow = h263p-2031-fld
allow = h263p-2032
allow = h263p-2032-fld
allow = h263p-2033
allow = h263p-2033-fld
allow = h263p-2034
allow = h263p-2034-fld
allow = h263p-2035
allow = h263p-2035-fld
allow = h263p-2036
allow = h263p-2036-fld
allow = h263p-2037
allow = h263p-2037-fld
allow = h263p-2038
allow = h263p-2038-fld
allow = h263p-2039
allow = h263p-2039-fld
allow = h263p-2040
allow = h263p-2040-fld
allow = h263p-2041
allow = h263p-2041-fld
allow = h263p-2042
allow = h263p-2042-fld
allow = h263p-2043
allow = h263p-2043-fld
allow = h263p-2044
allow = h263p-2044-fld
allow = h263p-2045
allow = h263p-2045-fld
allow = h263p-2046
allow = h263p-2046-fld
allow = h263p-2047
allow = h263p-2047-fld
allow = h263p-2048
allow = h263p-2048-fld
allow = h263p-2049
allow = h263p-2049-fld
allow = h263p-2050
allow = h263p-2050-fld
allow = h263p-2051
allow = h263p-2051-fld
allow = h263p-2052
allow = h263p-2052-fld
allow = h263p-2053
allow = h263p-2053-fld
allow = h263p-2054
allow = h263p-2054-fld
allow = h263p-2055
allow = h263p-2055-fld
allow = h263p-2056
allow = h263p-2056-fld
allow = h263p-2057
allow = h263p-2057-fld
allow = h263p-2058
allow = h263p-2058-fld
allow = h263p-2059
allow = h263p-2059-fld
allow = h263p-2060
allow = h263p-2060-fld
allow = h263p-2061
allow = h263p-2061-fld
allow = h263p-2062
allow = h263p-2062-fld
allow = h263p-2063
allow = h263p-2063-fld
allow = h263p-2064
allow = h263p-2064-fld
allow = h263p-2065
allow = h263p-2065-fld
allow = h263p-2066
allow = h263p-2066-fld
allow = h263p-2067
allow = h263p-2067-fld
allow = h263p-2068
allow = h263p-2068-fld
allow = h263p-2069
allow = h263p-2069-fld
allow = h263p-2070
allow = h263p-2070-fld
allow = h263p-2071
allow = h263p-2071-fld
allow = h263p-2072
allow = h263p-2072-fld
allow = h263p-2073
allow = h263p-2073-fld
allow = h263p-2074
allow = h263p-2074-fld
allow = h263p-2075
allow = h263p-2075-fld
allow = h263p-2076
allow = h263p-2076-fld
allow = h263p-2077
allow = h263p-2077-fld
allow = h263p-2078
allow = h263p-2078-fld
allow = h263p-2079
allow = h263p-2079-fld
allow = h263p-2080
allow = h263p-2080-fld
allow = h263p-2081
allow = h263p-2081-fld
allow = h263p-2082
allow = h263p-2082-fld<br/>
**Asterisk nat=force_rport,comedia with Routing: A Comprehensive Guide**
===========================================================

Q&A Section

Q: What is the purpose of using nat=force_rport,comedia in Asterisk? A: The nat=force_rport,comedia option in Asterisk is used to enable the use of the force_rport and comedia features. The force_rport feature forces the Asterisk server to use the remote port number in the SIP request, while the comedia feature enables the use of the COMEDIA (Connection-Oriented Media Transport) protocol.

Q: What is the difference between nat=force_rport and nat=force_rport,comedia? A: The nat=force_rport option only enables the use of the force_rport feature, while the nat=force_rport,comedia option enables both the force_rport and comedia features.

Q: How does the comedia feature work? A: The comedia feature enables the use of the COMEDIA protocol, which allows for the establishment of a connection-oriented media transport between the Asterisk server and the client. This feature is useful in scenarios where the client and server are behind a NAT (Network Address Translation) device.

Q: What is the purpose of using routing in this setup? A: In this setup, routing is used to establish connections between the phones and the Asterisk server across different subnetworks. By using routing, we can avoid the need for real NAT (Network Address Translation) and ensure that the connections are established correctly.

Q: How do I configure the routing in my setup? A: To configure the routing in your setup, you will need to add the following lines to your sip.conf file:

[general]
bindport = 5060
bindaddr = 0.0.0.0
disallow = all
allow = ulaw
allow = alaw
allow = g729
allow = gsm
allow = g726
allow = g726-24
allow = g726-40
allow = g729
allow = h263
allow = h263-1998
allow = h263-1998-fld
allow = h263p
allow = h263p-fld
allow = h263p-1998
allow = h263p-1998-fld
allow = h263p-2000
allow = h263p-2000-fld
allow = h263p-2001
allow = h263p-2001-fld
allow = h263p-2002
allow = h263p-2002-fld
allow = h263p-2003
allow = h263p-2003-fld
allow = h263p-2004
allow = h263p-2004-fld
allow = h263p-2005
allow = h263p-2005-fld
allow = h263p-2006
allow = h263p-2006-fld
allow = h263p-2007
allow = h263p-2007-fld
allow = h263p-2008
allow = h263p-2008-fld
allow = h263p-2009
allow = h263p-2009-fld
allow = h263p-2010
allow = h263p-2010-fld
allow = h263p-2011
allow = h263p-2011-fld
allow = h263p-2012
allow = h263p-2012-fld
allow = h263p-2013
allow = h263p-2013-fld
allow = h263p-2014
allow = h263p-2014-fld
allow = h263p-2015
allow = h263p-2015-fld
allow = h263p-2016
allow = h263p-2016-fld
allow = h263p-2017
allow = h263p-2017-fld
allow = h263p-2018
allow = h263p-2018-fld
allow = h263p-2019
allow = h263p-2019-fld
allow = h263p-2020
allow = h263p-2020-fld
allow = h263p-2021
allow = h263p-2021-fld
allow = h263p-2022
allow = h263p-2022-fld
allow = h263p-2023
allow = h263p-2023-fld
allow = h263p-2024
allow = h263p-2024-fld
allow = h263p-2025
allow = h263p-2025-fld
allow = h263p-2026
allow = h263p-2026-fld
allow = h263p-2027
allow = h263p-2027-fld
allow = h263p-2028
allow = h263p-2028-fld
allow = h263p-2029
allow = h263p-2029-fld
allow = h263p-2030
allow = h263p-2030-fld
allow = h263p-2031
allow = h263p-2031-fld
allow = h263p-2032
allow = h263p-2032-fld
allow = h263p-2033
allow = h263p-2033-fld
allow = h263p-2034
allow = h263p-2034-fld
allow = h263p-2035
allow = h263p-2035-fld
allow = h263p-2036
allow = h263p-2036-fld
allow = h263p-2037
allow = h263p-2037-fld
allow = h263p-2038
allow = h263p-2038-fld
allow = h263p-2039
allow = h263p-2039-fld
allow = h263p-2040
allow = h263p-2040-fld
allow = h263p-2041
allow = h263p-2041-fld
allow = h263p-2042
allow = h263p-2042-fld
allow = h263p-2043
allow = h263p-2043-fld
allow = h263p-2044
allow = h263p-2044-fld
allow = h263p-2045
allow = h263p-2045-fld
allow = h263p-2046
allow = h263p-2046-fld
allow = h263p-2047
allow = h263p-2047-fld
allow = h263p-2048
allow = h263p-2048-fld
allow = h263p-2049
allow = h263p-2049-fld
allow = h263p-2050
allow = h263p-2050-fld
allow = h263p-2051
allow = h263p-2051-fld
allow = h263p-2052
allow = h263p-2052-fld
allow = h263p-2053
allow = h263p-2053-fld
allow = h263p-2054
allow = h263p-2054-fld
allow = h263p-2055
allow = h263p-2055-fld
allow = h263p-2056
allow = h263p-2056-fld
allow = h263p-2057
allow = h263p-2057-fld
allow = h263p-2058
allow = h263p-2058-fld
allow = h263p-2059
allow = h263p-2059-fld
allow = h263p-2060
allow = h263p-2060-fld
allow = h263p-2061
allow = h263p-2061-fld
allow = h263p-2062
allow = h263p-2062-fld
allow = h263p-2063
allow = h263p-2063-fld
allow = h263p-2064
allow = h263p-2064-fld
allow = h263p-2065
allow = h263p-2065-fld
allow = h263p-2066
allow = h263p-2066-fld
allow = h263p-2067
allow = h263p-2067-fld
allow = h263p-2068
allow = h263p-2068-fld
allow = h263p-2069
allow = h263p-2069-fld
allow = h263p-2070
allow = h263p-2070-fld
allow = h263p-2071
allow = h263p-2071-fld
allow = h263p-2072
allow = h263p-2072-fld
allow = h263p-2073
allow = h263p-2073-fld
allow = h263p-2074
allow = h263p-2074-fld
allow = h263p-2075
allow = h263p-2075-fld
</code></pre>