From Fedora Project Wiki
No edit summary
Line 119: Line 119:
channel => 3
channel => 3
</pre>
</pre>
----
[[Category:Draft_documentation]]

Revision as of 07:25, 9 June 2009

Motivation

  • Being able to have developers call me with my fedoraproject.org SIP address.
  • Being able to call developers using my normal phones without a land line.
  • Being able to have other people call me using POTS through Fedora Talk. (Note I asked about the policy on this and for now it's OK if it doesn't get abused. But there is no promise that this service will continue in the future.)

Why Asterisk?

I have an analog tdm card that needs the dahdi driver as the zaptel driver will not work on the recent kernels. Callweaver in Fedora does not yet work with dahdi. I am not aware of other software that will work with my hardware, though there are some other choices if you are just going to use SIP.

Prerequisites

  • You need to have set up your VOIP account.
  • If you are using special hardware the dahdi drivers are not part of Fedora. Currently for Fedora F11 you need to build them from source. But in many cases 3rd party repos carry them. The issue is the drivers have not been upstreamed.
  • You need to have Asterisk installed. Though a lot of this will also apply to Callweaver which is a fork of Asterisk.

What I learned while getting this to work

  • Even to make inbound SIP calls to Fedora Talk, you must be authenticated.
    • I am not sure if this is to prevent VOIP spam, just an oversight or something else.
    • When using SIP clients you can do this by setting up fedoraproject.org as an outbound proxy.
  • That your password is supplied differently when using it in an auth command as opposed to a secret command. Using the secret command will work when registering (to have calls directed to your server) with the fedoraproject.org server, but not when using it as a proxy (to make calls to other developers).
  • Unless you use pedantic some short cuts are taken with loop checking that breaks some loopback testing.
  • The default registration time is only 2 minutes. For long time connections you can set this to an hour to reduce pinging the fedoraproject.org server.
  • If you run asterisk as root you create some log files owned by the wrong account that will break running it as a service. So use the service asterisk commands to start and stop the service during testing. sip show registry was particularly useful.
  • You can do interactive debugging using the asterisk -r command to attach to a running asterisk daemon. This you can run as root. help will give you a list of commands to play with.
  • If you use a peer name instead of a hostname in the register command this seems to cause dns lookups of the peer name under some circumstances which generates some warnings.
  • For inbound calls from a server you have registered at the extension will be the default start extension, s. If you have inbound SIP calls directly to your server the start extension will be the username or the empty string if no username was given.
  • To match an empty string in a dial plan you can use _! (though that really matches any string so you need to be careful).

Config files

When you install asterisk a bunch of config files get created in /etc/asterisk. The main ones I played with in getting this to work were sip.conf, extensions.conf and chan_dahdi.conf. I simplified these files greatly in the hope of not accidentally leaving some feature enabled that could easily be abused from the outside. And by including just the simplified files it makes it easier to see what needs to be done to make things work with Fedora Talk.

sip.conf

[general]
pedanic=on ; This uses a more careful loop checking method needed for loopback testing
allowoverlap=no
allowtransfer=no
udpbindaddr=0.0.0.0
tcpenable=yes
tlsenable=no
tcpbindaddr=0.0.0.0
transport=udp,tcp
defaultexpiry=3600 ; The default of 120 is kind of short
register => bruno:password_goes_here@fedoraproject.org

[fedora]
context=fedora
type=peer
host=fedoraproject.org
fromuser=bruno
fromdomain=fedoraproject.org
auth=bruno:password_goes_here@fedoraproject.org ; Don't use 'secret' as it breaks calling fedora talk extensions

[home]
context=home
type=peer
host=bruno.wolff.to
fromuser=bruno
fromhost=bruno.wolff.to

extensions.conf

[general]
static=yes
writeprotect=no
clearglobalvars=no
[globals]
[upstairs]
exten => s,1,answer
exten => s,2,dial(dahdi/2) ; pickup to call downstairs
exten => s,3,hangup

[downstairs]
exten => _#,1,answer
exten => _#,2,dial(dahdi/1) ; # to call upstairs
exten => _#,3,hangup
exten => _X.,1,answer
exten => _X.,2,dial(sip/${EXTEN}@fedora) ; Connect to fedora project extension
exten => _X.,3,hangup
exten => _1*!,1,answer
exten => _1*!,2,dial(sip/bruno@fedora) ; Loop back through fedora
exten => _1*!,3,hangup
exten => _2*!,1,answer
exten => _2*!,2,dial(sip/home) ; Loop back through home
exten => _2*!,3,hangup

[test] ; Test phone usually not plugged in
exten => s,1,answer
;exten => s,2,dial(sip/bruno@fedora)
;exten => s,2,dial(sip/home)
exten => s,2,dial(dahdi/2)
exten => s,3,hangup

[fedora]
exten => s,1,answer
exten => s,2,dial(dahdi/1r4&dahdi/2r4) ; Inbound fedora calls ring upstairs and downstairs with distinctive ring
exten => s,3,hangup

[home]
exten => _!,1,answer
exten => _!,2,dial(dahdi/1r4&dahdi/2r4) ;Inbound calls direct to my sip server ring upstairs and downstairs with distinctive ring
exten => _!,3,hangup

chan_dahdi.conf

[channels]
;
echocancel=yes
group=1
callgroup=1
pickupgroup=1

context=upstairs
immediate=yes ; Upstairs phone works in bat phone mode
channel => 1

context=downstairs
immediate=no ; Downstairs phone gets a dial tone
channel => 2

context=test
immediate=yes ; Test phone works in bat phone mode
channel => 3