├── README ├── autoload_configs ├── acl.conf.xml ├── cdr_csv.conf.xml ├── conference.conf.xml ├── console.conf.xml ├── db.conf.xml ├── event_socket.conf.xml ├── hash.conf.xml ├── httapi.conf.xml ├── ivr.conf.xml ├── local_stream.conf.xml ├── logfile.conf.xml ├── lua.conf.xml ├── modules.conf.xml ├── opus.conf.xml ├── post_load_modules.conf.xml ├── sofia.conf.xml ├── spandsp.conf.xml ├── switch.conf.xml └── timezones.conf.xml ├── dialplan ├── public.xml └── public │ └── 10_gateway_inbound.xml ├── directory └── stub.xml ├── docs └── tutorial_01_simple_pbx.md ├── freeswitch.xml ├── ivr_menus └── stub.xml ├── lang └── en │ ├── en.xml │ └── ivr │ └── stub.xml ├── sip_profiles ├── external-ipv6.xml ├── external-ipv6 │ └── stub.xml ├── external.xml ├── external │ └── stub.xml ├── internal-ipv6.xml ├── internal.xml └── internal │ └── stub.xml ├── tls └── .stub └── vars.xml /README: -------------------------------------------------------------------------------- 1 | Minimal FreeSWITCH configuration 2 | ================================ 3 | 4 | This is a minimalistic FreeSWITCH configuration. It does not do anyting, 5 | yet it allows starting the FreeSWITCH daemon and connecting to its 6 | console with fs_cli. 7 | 8 | The purpose of this configuration is to provide a base for new projects, 9 | so that you don't have to clean up the vanilla configuration from 10 | unneeded features. 11 | 12 | Tested on Debian with packages from [http://files.freeswitch.org]. 13 | 14 | 15 | Usage if you do everethyng as root: 16 | ----------------------------------- 17 | cd /etc 18 | git clone https://github.com/voxserv/freeswitch_conf_minimal.git freeswitch 19 | 20 | 21 | 22 | Usage if you work as multiple non-root users: 23 | --------------------------------------------- 24 | echo "umask 0007" >>~/.profile 25 | umask 0007 26 | sudo adduser jsmith freeswitch 27 | sudo mkdir /etc/freeswitch 28 | sudo chgrp freeswitch /etc/freeswitch 29 | sudo chmod g+ws /etc/freeswitch 30 | cd /etc/freeswitch 31 | git init --shared=0660 32 | git pull https://github.com/voxserv/freeswitch_conf_minimal.git master 33 | 34 | 35 | 36 | Installing FreeSWITCH on Debian Jessie 37 | -------------------------------------- 38 | 39 | apt-get update && apt-get install -y curl git 40 | 41 | cat >/etc/apt/sources.list.d/freeswitch.list < 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /autoload_configs/cdr_csv.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /autoload_configs/conference.conf.xml: -------------------------------------------------------------------------------- 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 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 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 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /autoload_configs/console.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 33 | 34 | 35 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /autoload_configs/db.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /autoload_configs/event_socket.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /autoload_configs/hash.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /autoload_configs/httapi.conf.xml: -------------------------------------------------------------------------------- 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 | 38 | 39 | 40 | 41 | 42 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 94 | 95 | 96 | 97 | 98 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 112 | 113 | 114 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /autoload_configs/ivr.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /autoload_configs/local_stream.conf.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /autoload_configs/logfile.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /autoload_configs/lua.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /autoload_configs/modules.conf.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /autoload_configs/opus.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /autoload_configs/post_load_modules.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /autoload_configs/sofia.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /autoload_configs/spandsp.conf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 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 | -------------------------------------------------------------------------------- /autoload_configs/switch.conf.xml: -------------------------------------------------------------------------------- 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 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 74 | 75 | 76 | 82 | 83 | 84 | 90 | 91 | 92 | 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 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /autoload_configs/timezones.conf.xml: -------------------------------------------------------------------------------- 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 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | -------------------------------------------------------------------------------- /dialplan/public.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /dialplan/public/10_gateway_inbound.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /directory/stub.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/directory/stub.xml -------------------------------------------------------------------------------- /docs/tutorial_01_simple_pbx.md: -------------------------------------------------------------------------------- 1 | Simple PBX tutorial 2 | =================== 3 | 4 | Copyright (c) 2015 Stanislav Sinyagin 5 | 6 | This document presents a short tutorial that allows you to start using a 7 | FreeSWITCH server as a basic PBX. It is part of the minimal FreeSWITCH 8 | configuration which is available at 9 | https://github.com/voxserv/freeswitch_conf_minimal 10 | 11 | This document does not try to cover all aspects of FreeSWITCH 12 | configuration and maintenance, and it is highly recommended to read the 13 | book first: 14 | https://www.packtpub.com/networking-and-servers/freeswitch-12 15 | 16 | After installing the minimal configuration, your FreeSWITCH server is 17 | able to process SIP requests, but its dialplan is empty, so the calls 18 | would not go anywhere. This short tutorial lists the steps to get 19 | started with a simple PBX configuration. 20 | 21 | Further in this document, we refer to the standard FreeSWITCH 22 | configuration as "vanilla". The vanilla configuration introduces a 23 | dialplan that demonstrates lots of FreeSWITCH features, but it takes too 24 | much time to clean it up for your future production configuration. Also 25 | the vanilla configuration aliases all domains to the server's IPv4 26 | address, making the domain name part in user registrations 27 | indistinguishable. The minimal configuration enables the "multi-tenant" 28 | scenario, where domain name part of SIP users makes difference. Even if 29 | you're not planning multiple domains on our FreeSWITCH server, 30 | multi-tenant configuration stil has its benefits. One of the benefits is 31 | that you can mix SIP users that connect via IPv4 and IPv6 in the same 32 | domain and let them communicate to each ther. 33 | 34 | 35 | DNS configuration 36 | ----------------- 37 | 38 | First of all, you need to choose a domain name for your SIP service. Or 39 | even better, two different domain names: 1) for internal users to use 40 | for SIP client registration; 2) for external SIP peers to send 41 | unauthenticated calls to your server. 42 | 43 | In this example, we use `int.example.net` as a domain name for internal 44 | SIP client registrations, and `pub.example.net` as a domain name for 45 | external peers to call out to our server. 46 | 47 | Thus, the SIP clients would use accounts like `701@int.example.net` for 48 | registering on our server, and external peers would use SIP URL like 49 | `sip:attendant@pub.example.net` to place unauthenticated calls to our 50 | server. 51 | 52 | If you don't plan to receive calls via SIP URL from external peers, the 53 | DNS entry for unauthenticated calls is not necessary (although some ITSP 54 | use this to accept calls on DID numbers). 55 | 56 | Most modern SIP clients lookup first a NAPTR DNS record in order to find 57 | out the SIP service that is serving the domain. Some DNS hosting 58 | providers (`godaddy.com`, for example) do not allow adding NAPTR records 59 | via their DNS editing GUI. A simple solution would be to point an NS 60 | record for a subdomain to some alternative DNS hosting, such as 61 | `dns.he.net`. 62 | 63 | It is also not too dramatic if there is no NAPTR record for your 64 | domain. Most clients fall back to the SRV record if they don't find a 65 | NAPTR record for the SIP domain. 66 | 67 | Also if a Windows server is used as a DNS resolver in your LAN, the 68 | NAPTR record queries may produce unpredictable results. In one occasion, 69 | I had to remove the NAPTR record from a domain, because Gigaset C610IP 70 | phone failed to resolve the service whle Windows server was used as the 71 | default resolver. 72 | 73 | A NAPTR record should point to one or several SRV DNS records. The 74 | standard allows you to put a TCP SRV record with a higher priorty, but 75 | not all SIP clients would understand that. FreeSWITCH supports TCP 76 | transport for SIP, listening on the same ports as the UDP transport. 77 | 78 | By default, FreeSWITCH uses port 5060 for authenticated SIP requests, 79 | and port 5080 for non-authenticated ones. Thus, the SRV records for 80 | `int.example.net` should point to UDP or TCP port 5060, and use port 81 | 5080 for `pub.example.net` records. 82 | 83 | 84 | The following example creates the records in a BIND name server: 85 | 86 | ``` 87 | ;;; inside the zone file for example.net 88 | pbx01 IN A 198.51.100.10 89 | pbx01 IN AAAA 2001:DB8::0A 90 | _sip._udp.int IN SRV 10 0 5060 pbx01 91 | int IN NAPTR 110 100 S SIP+D2U "" _sip._udp.int 92 | _sip._udp.pub IN SRV 10 0 5080 pbx01 93 | pub IN NAPTR 110 100 S SIP+D2U "" _sip._udp.pub 94 | ``` 95 | 96 | Dialplan contexts 97 | ----------------- 98 | 99 | FreeSWITCH dialplan consists of contexts -- independent sets of matching 100 | rules and actions for the calls. Each call enters a context, and later 101 | it may be transferred to another context, or bridged with some remote 102 | party, or a dialplan application can be executed on it according to the 103 | matching rules and actions. 104 | 105 | The vanilla configuration defines two dialplan contexts: "public" is 106 | where all unauthenticated calls are landing, and "default" where calls 107 | to and from registered users are processed. 108 | 109 | The minimal configuration defines only the "public" context, leaving you 110 | the freedom to define other contexts as needed. 111 | 112 | The structure and contents of a dialplan are described in detail in 113 | FreeSWITCH wiki and in FreeSWITCH book. It is important to understand 114 | the two-pass processing workflow, the `continue` attribute in extensions 115 | and `break` attribute in conditions. Also you need to understand the 116 | meaning of `inline` attribute in the action statements. 117 | 118 | 119 | `public` dialplan context 120 | ------------------------- 121 | 122 | The file `dialplan/public/10_gateway_inbound.xml` in the minimal 123 | configuration defines a simple dispatcher for inbound calls from SIP 124 | gateways. It expects the SIP gateway to define two variables: 125 | `target_context` and `domain`, and if both are defined, the inbound call 126 | is transferred into the specified context, with `${domain_name}` 127 | variable set to the domain name. This allows you, for example, to use 128 | multiple SIP trunks in a multi-tenant configuration, so that each trunk 129 | is used for a different tenant and its own context. The following 130 | example of a SIP gateway demonstrates the feature: 131 | 132 | ``` 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 147 | 149 | 150 | 151 | ``` 152 | 153 | Another common approach is to set up matching patterns in the public 154 | context, each matching a particular phone number or a range of numbers, 155 | and making a transfer to a specific extension: 156 | 157 | ``` 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | ``` 170 | 171 | 172 | `int.example.net` dialplan context 173 | ---------------------------------- 174 | 175 | In this example, registered users can dial 7xx to reach other registered 176 | users, 500 for audio conference (unmodetared, anyone can join), 520 to 177 | check voicemail, and anything that starts with `0` or `1` or `+` goes to 178 | PSTN. Calls to PSTN are processed in a separate context -- this is done 179 | to simplify the logic and to let you manage PSTN calls from different 180 | internal contexts in a single place. 181 | 182 | This example dialplan allows specifying the fallback path for every 183 | extension, by defining the variable `fallback_route` in user 184 | directory. The value of this variable should be `voicemail` for falling 185 | back to the voicemail system, or `transfer DEST CONTEXT` to transfer the 186 | call to a corresponding destination in specified context. This allows 187 | for the flexibility of defining the fallback routes for each user. Keep 188 | in mind that if you are using `mod_xml_curl` for user directory, each 189 | execution of `user_data` function will trigger the HTTP request for this 190 | user. Thus, defining and checking too many variables for a user may 191 | cause performance degradation. 192 | 193 | Note that in the fallback transfer action, we copy the original caller 194 | ID from the variable `caller_id_number`. If the outbound connection 195 | allows us to set the caller ID, it will be preserved from the original 196 | inbound call. 197 | 198 | ``` 199 | 200 | 201 | 202 | 203 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 222 | 223 | 225 | 227 | 228 | 229 | 231 | 232 | 233 | 235 | 236 | 237 | 238 | 240 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | ``` 273 | 274 | 275 | `pstnout` dialplan context 276 | -------------------------- 277 | 278 | This is an example of dialplan context that places the outbound call to 279 | external telephony providers. If you are building a multi-tenant PBX, 280 | you may want to have separate dialplan contexts for each tenant, so that 281 | their calls are billed to different accounts. 282 | 283 | This example demonstrates the rules for number normnalization: the 284 | caller is supposed to be in Switzerland and is dialing a Swiss local 285 | number with one leading zero, or an international number with two 286 | leading zeros. These rules are needed to build a full E.164 number 287 | before placing the call to Voxbeam. The rules apply to callee and 288 | calling numbers accordingly. 289 | 290 | Note that we use the channel variable `outbound_caller_id_number` to 291 | determine the caller ID. This is not a standard variable, and it needs 292 | to be set somewhere previously in the dialplan. In our example, it is 293 | set in the user directory and in fallback transfer condition. 294 | 295 | ``` 296 | 297 | 298 | 299 | 300 | 301 | 303 | 304 | 305 | 307 | 308 | 309 | 311 | 312 | 313 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | ``` 347 | 348 | `voxbeam_outbound` gateway 349 | -------------------------- 350 | 351 | Voxbeam uses authentication by SIP IP address, so we need to define a 352 | gateway which does not register on the provider, and sends the caller ID 353 | in From: field. 354 | 355 | ``` 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | ``` 365 | 366 | 367 | User directory 368 | -------------- 369 | 370 | The user directory is quite standard as described in FreeSWITCH wiki. An 371 | important detail is that the domain name should be specified explicitly, 372 | and it should match the DNS records as described above. 373 | 374 | You have a choice of specifying the password in clear text or as MD5 375 | hashes for better security. 376 | 377 | In this example, the user 701 has the fallback route to a mobile number, 378 | 702 falls back into voicemail, and 703 does not have any fallback at 379 | all. 380 | 381 | ``` 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | ``` 428 | 429 | 430 | Firewall settings 431 | ----------------- 432 | 433 | The following example is deploying `iptables` rules that limit the rate 434 | of SIP requests to your server, thus preventing attackers from 435 | overloading your FreeSWITCH instance. Depending on your scalability 436 | requirements, the rate of allowed SIP messages can be increased. You may 437 | also have requirements for a more strict firewall policy, and add rules 438 | that reject completely certain kind of traffic. 439 | 440 | The following example is suitable for Debian and can be simply 441 | copy-pasted to the command line. 442 | 443 | ``` 444 | apt-get install -y iptables-persistent 445 | 446 | ##### IPv4 rules ##### 447 | iptables -N dos-filter-sip-external 448 | 449 | iptables -A INPUT -p udp -m udp --dport 5060 \ 450 | -j dos-filter-sip-external 451 | 452 | iptables -A INPUT -p tcp -m tcp --dport 5060 \ 453 | -j dos-filter-sip-external 454 | 455 | iptables -A INPUT -p udp -m udp --dport 5080 \ 456 | -j dos-filter-sip-external 457 | 458 | iptables -A dos-filter-sip-external \ 459 | -m hashlimit --hashlimit 5/sec \ 460 | --hashlimit-burst 30 --hashlimit-mode srcip \ 461 | --hashlimit-name SIPMSG --hashlimit-htable-size 24593 \ 462 | --hashlimit-htable-expire 90000 -j RETURN 463 | 464 | iptables -A dos-filter-sip-external -j \ 465 | REJECT --reject-with icmp-admin-prohibited 466 | 467 | iptables -N dos-filter-ssh 468 | 469 | iptables -I INPUT -p tcp -m tcp --dport 22 \ 470 | --tcp-flags FIN,SYN,RST,ACK SYN -j dos-filter-ssh 471 | 472 | iptables -A dos-filter-ssh -m hashlimit --hashlimit 3/min \ 473 | --hashlimit-burst 10 --hashlimit-mode srcip,dstip \ 474 | --hashlimit-name ssh_hash --hashlimit-htable-expire 60000 \ 475 | -j ACCEPT 476 | 477 | iptables -A dos-filter-ssh -j DROP 478 | 479 | iptables-save > /etc/iptables/rules.v4 480 | 481 | ##### IPv6 rules ##### 482 | 483 | ip6tables -N dos-filter-sip-external 484 | 485 | ip6tables -A INPUT -p udp -m udp --dport 5060 \ 486 | -j dos-filter-sip-external 487 | 488 | ip6tables -A INPUT -p tcp -m tcp --dport 5060 \ 489 | -j dos-filter-sip-external 490 | 491 | ip6tables -A INPUT -p udp -m udp --dport 5080 \ 492 | -j dos-filter-sip-external 493 | 494 | ip6tables -A dos-filter-sip-external \ 495 | -m hashlimit --hashlimit 5/sec \ 496 | --hashlimit-burst 30 --hashlimit-mode srcip \ 497 | --hashlimit-name SIPMSG --hashlimit-htable-size 24593 \ 498 | --hashlimit-htable-expire 90000 -j RETURN 499 | 500 | ip6tables -A dos-filter-sip-external -j \ 501 | REJECT --reject-with icmp6-adm-prohibited 502 | 503 | ip6tables -N dos-filter-ssh 504 | 505 | ip6tables -I INPUT -p tcp -m tcp --dport 22 \ 506 | --tcp-flags FIN,SYN,RST,ACK SYN -j dos-filter-ssh 507 | 508 | ip6tables -A dos-filter-ssh -m hashlimit --hashlimit 3/min \ 509 | --hashlimit-burst 10 --hashlimit-mode srcip,dstip \ 510 | --hashlimit-name ssh_hash --hashlimit-htable-expire 60000 \ 511 | -j ACCEPT 512 | 513 | ip6tables -A dos-filter-ssh -j DROP 514 | 515 | ip6tables-save > /etc/iptables/rules.v6 516 | ``` 517 | 518 | 519 | Conclusion 520 | ---------- 521 | 522 | After following this tutorial, you would get a basic PBX which allows 523 | the SIP users to register and place and receive calls. It also 524 | demonstrates various features, such as fallback scenario when the SIP 525 | user is not available. 526 | 527 | There are many other topics which might be interesting to implement, 528 | such as: 529 | 530 | 1. Receiving and sending faxes; 531 | 2. Deploying WebRTC to let the users use their browsers as VoIP clients; 532 | 3. Setting up a static IVR; 533 | 4. Programming the server to look up some databases before connecting a call; 534 | 5. Queues, call centers, virtual assistants, etc. 535 | 536 | Some useful scripts and configurations are available on Github and in my 537 | blog: 538 | 539 | * https://github.com/voxserv/ 540 | * https://github.com/xlab1 541 | * https://txlab.wordpress.com/tag/freeswitch/ 542 | 543 | 544 | -------------------------------------------------------------------------------- /freeswitch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | 21 | 22 | 23 |
24 | 25 |
26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
36 | 37 |
38 | 39 |
40 | -------------------------------------------------------------------------------- /ivr_menus/stub.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/ivr_menus/stub.xml -------------------------------------------------------------------------------- /lang/en/en.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 22 | -------------------------------------------------------------------------------- /lang/en/ivr/stub.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/lang/en/ivr/stub.xml -------------------------------------------------------------------------------- /sip_profiles/external-ipv6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 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 | -------------------------------------------------------------------------------- /sip_profiles/external-ipv6/stub.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/sip_profiles/external-ipv6/stub.xml -------------------------------------------------------------------------------- /sip_profiles/external.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 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 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 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 | -------------------------------------------------------------------------------- /sip_profiles/external/stub.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/sip_profiles/external/stub.xml -------------------------------------------------------------------------------- /sip_profiles/internal-ipv6.xml: -------------------------------------------------------------------------------- 1 | 2 | 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 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /sip_profiles/internal.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 39 | 40 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 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 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 123 | 124 | 125 | 126 | 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 | 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 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 321 | 322 | 323 | 324 | 325 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 367 | 368 | 371 | 372 | 373 | 377 | 378 | 379 | 380 | 385 | 386 | 387 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 402 | 403 | 404 | 405 | 406 | -------------------------------------------------------------------------------- /sip_profiles/internal/stub.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/sip_profiles/internal/stub.xml -------------------------------------------------------------------------------- /tls/.stub: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/voxserv/freeswitch_conf_minimal/7bd0994c9b925a09501903bb5c8aa5fd303d50de/tls/.stub -------------------------------------------------------------------------------- /vars.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 25 | 26 | 27 | 38 | 39 | 40 | 41 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | --------------------------------------------------------------------------------