Arik Raffael Funke
2006-Nov-06 04:04 UTC
[asterisk-users] Ring locally when home or roadwarrior via IAX when away
Hi, want to have calls directed to internal fixed phones, when my employees are home and automatically to their IAX connection when they are logged in remotely. How do I do this? The picture is as follows: --- HOME --- - user logged in via IAX with local IP adress - fixed line should ring - IAX should not ring --- ON THE ROAD --- - user logged in via IAX with an EXTERNAL IP - fixed line should not ring - but IAX should be called. I guess, in short my question reduces to: How do I find the IP adress of a specific iax client? Thanks in advance for the help. Regards, Arik
Anselm Martin Hoffmeister
2006-Nov-06 06:29 UTC
[asterisk-users] Ring locally when home or roadwarrior via IAX when away
Am Montag, den 06.11.2006, 11:04 +0000 schrieb Arik Raffael Funke:> Hi, > > want to have calls directed to internal fixed phones, when my employees > are home and automatically to their IAX connection when they are logged > in remotely. How do I do this? > > The picture is as follows: > > --- HOME --- > - user logged in via IAX with local IP adress > - fixed line should ring > - IAX should not ring > > --- ON THE ROAD --- > - user logged in via IAX with an EXTERNAL IP > - fixed line should not ring > - but IAX should be called. > > I guess, in short my question reduces to: How do I find the IP adress of > a specific iax client?I do not currently run IAX, but SIP clients only. Nevertheless, once connected, a database entry "appears" containing login info. It seems to disappear once the client de-registers, so assuming that IAX does the same, this could do the trick. For SIP, the database entry would be "SIP/Registry/sip507" for my Laptop which has username sip507 in sip.conf section sip507 (I do not know which of those two selects the name in the database). The value in the database looks like 80.136.xxx.xxx:5060:1800:sip507:sip:sip507@80.136.xxx.xxx;uniq=49XXXXXXXXXXXXXXXXXXXXXXXXXXXX (with the IP address leading) With a set of statements like exten => _5XX,1,Set(IPADDR=${CUT(${DB(SIP/sip${EXTEN})},:,1)}) exten => _5XX,2,GotoIf($["10.0." = "${IPADDR:0:5}"]?100) exten => _5XX,3,GotoIf($["" = "${IPADDR}"]?100) exten => _5XX,4,NoOp(Stuff for calling the client via SIP) exten => _5XX,100,NoOp(Stuff for calling via the phoneline, cause user is local) Note that line _5XX,3 is necessary to capture the case of "client not logged in via SIP at all" - you might as well activate VoiceMail here or whatever. In my opinion calling the client via SIP right then is not a good idea :-), hence the GotoIf for calling via the phoneline. I would try to achieve this with my SIPclient this way, you will have to find out wether IAX works similarly. This is untested though, but I hope to give you a useful hint here. BR, Anselm
Arik Raffael Funke
2006-Nov-06 12:49 UTC
[asterisk-users] Re: Ring locally when home or roadwarrior via IAX when away
Anselm Martin Hoffmeister wrote:> Am Montag, den 06.11.2006, 11:04 +0000 schrieb Arik Raffael Funke: >> I guess, in short my question reduces to: How do I find the IP adress of >> a specific iax client? > With a set of statements like > > exten => _5XX,1,Set(IPADDR=${CUT(${DB(SIP/sip${EXTEN})},:,1)}) > exten => _5XX,2,GotoIf($["10.0." = "${IPADDR:0:5}"]?100) > exten => _5XX,3,GotoIf($["" = "${IPADDR}"]?100) > exten => _5XX,4,NoOp(Stuff for calling the client via SIP) > exten => _5XX,100,NoOp(Stuff for calling via the phoneline, cause user > is local) > > This is untested though, but I hope to give you a useful hint here.Thanks Anselm. Your solution does work for iax as well, except for some typos. I have it working with following set of commands now, in case anybody is wondering: exten => s,1,Set(IPADDR=${CUT(DB(IAX/Registry/arik)|:|1)}) exten => s,2,GotoIf($["192.168.0." = "${IPADDR:0:10}"]?100) exten => s,3,GotoIf($["" = "${IPADDR}"]?100) exten => s,4,Dial(${ARIK_WEB},,t) exten => s,100,Dial(${ARIK},,t) Note ${ARIK} contains the fixed line channel, ${ARIK_WEB} the IAX channel. arik is the iax login username. Regards, Arik