forked from xlab1/sipfe_kamailio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kamailio.cfg
264 lines (196 loc) · 5.67 KB
/
kamailio.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#!KAMAILIO
################################################################
#
# This is a front-end SIP proxy configuration for the xlab1 project
# See for more details: https://txlab.wordpress.com/tag/xlab1/
# The configuration requires Kamailio version 3.3.x
#
# This work is licensed under a Creative Commons Attribution 3.0 License
# Author: Stanislav Sinyagin <[email protected]>
#
################################################################
#!define WITH_DEBUG
####### Defined Values #########
#!define DBURL "text:///opt/sipfe/etc/kamailio_db"
#!define BACKEND_NET4 10.100.0.0/24
#!define BACKEND_NET6 2a02:200:8:100::/64
####### Global Parameters #########
#!ifdef WITH_DEBUG
debug=4
log_stderror=no
#!else
debug=2
log_stderror=no
#!endif
memdbg=5
memlog=5
log_facility=LOG_LOCAL0
fork=yes
children=2
auto_aliases=no
# to avoid simple attacks, use unconventional port
port=5066
# this makes it listen on all ipv6 addresses
auto_bind_ipv6=1
dns_try_ipv6=yes
# let kamailio choose the right source IP address
mhomed=1
# life time of TCP connection when there is no traffic
# - a bit higher than registration expires to cope with UA behind NAT
tcp_connection_lifetime=3605
####### Modules Section ########
mpath="/opt/sipfe/lib64/kamailio/modules_k/:/opt/sipfe/lib64/kamailio/modules/"
loadmodule "db_text.so"
loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so"
loadmodule "path.so"
loadmodule "domain.so"
loadmodule "dispatcher.so"
loadmodule "nathelper.so"
loadmodule "rtpproxy.so"
#!ifdef WITH_DEBUG
loadmodule "debugger.so"
#!endif
# ----------------- setting module-specific parameters ---------------
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)
modparam("nathelper", "received_avp", "$avp(RECEIVED)")
modparam("nathelper", "nortpproxy_str", "a=sdpmangled:yes\r\n")
modparam("path", "use_received", 1)
modparam("domain", "db_url", DBURL)
modparam("dispatcher", "db_url", DBURL)
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:22222")
#!ifdef WITH_DEBUG
# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)
#!endif
####### Routing Logic ########
route {
if (!sanity_check()) {
exit;
}
if ( !mf_process_maxfwd_header("10") )
{
sl_send_reply("483","To Many Hops");
xlog("L_NOTICE", "$si $rm $ru -- too many hops\n");
exit;
}
if (af==INET)
{
force_rport();
if (src_ip != BACKEND_NET4)
{
# SIP request packet client->backend
if( !loose_route() )
{
if (!lookup_domain("$td", "dattr_")) {
xlog("L_ERR", "$si $rm $ru -- domain \"$td\" is not " +
"found in domain table\n");
drop();
}
if (!defined $avp(dattr_routeset))
{
xlog("L_ERR",
"$si $rm $ru -- attribute \"routeset\" is " +
"undefined for domain $td\n");
drop();
}
if( !ds_select_dst(4000 + $avp(dattr_routeset), "1") )
{
drop();
}
}
if (nat_uac_test("19")) {
if (method=="REGISTER") {
fix_nated_register();
} else {
fix_nated_contact();
}
}
add_path_received();
rtpproxy_manage("cwei");
record_route();
}
else
{
# SIP request packet backend->client
# Invites from backend contain Route field and it should be used
# to reach the registered client
loose_route();
rtpproxy_manage("cwie");
record_route();
}
}
else
{
# IPv6: no NAT traversal, just pure routing
if (src_ip != BACKEND_NET6)
{
# SIP request packet client->backend
if( !loose_route() )
{
if (!lookup_domain("$td", "dattr_")) {
xlog("L_ERR", "$si $rm $ru -- domain \"$td\" is not " +
"found in domain table\n");
drop();
}
if (!defined $avp(dattr_routeset))
{
xlog("L_ERR",
"$si $rm $ru -- attribute \"routeset\" is " +
"undefined for domain $td\n");
drop();
}
if( !ds_select_dst(6000 + $avp(dattr_routeset), "1") )
{
drop();
}
}
add_path_received();
record_route();
}
else
{
# SIP request packet backend->client
record_route();
}
}
forward();
}
onreply_route {
if (af==INET)
{
if(src_ip != BACKEND_NET4)
{
# SIP reply packet client->backend
rtpproxy_manage("cwie");
fix_nated_contact();
}
else
{
# SIP reply packet backend->client
rtpproxy_manage("cwei");
}
}
return(1);
}
# Local Variables:
# mode: sh
# sh-indent-after-if: 0
# indent-tabs-mode: nil
# tab-width: 4
# End: