asterisk settings HKBN 2b
Sample Asterisk config for Hong Kong BroadBand
Assumptions:
- Account created starting October 2005 (if your account is before October 2005 or is NOT a "2b" account, then you want to look here)
- Softphone password: abcdef9876
- Phone number: 35129898
sip.conf
[general]
port=5060
bindaddr=0.0.0.0
pedantic=no
autocreatepeer=no
allow=all
canreinvite=no
nat=no
context=from-sip
;;; Beginning of stuff for NAT support
externip=my.static.ip.address.or.Fully.Qualified.Dynamic.Domain.Name
localnet=my.local.internal.ip.address/net.mask
;;; End of stuff for NAT support
register => 35129898:abcdef9876@s2hkbntel.net:5060/35129898
;;; If your account was created after Nov 2005, the register line should be:
;;; register => 35129898hk:abcdef9876@s2hkbntel.net:5060/35129898
[s2hkbntel.net]
type=peer
username=35129898
;;; If your account was created after Nov 2005, the above line should be:
;;; username=35129898hk
secret=abcdef9876
port=5060
host=s2hkbntel.net
fromuser=35129898
;;; If your account was created after Nov 2005, the above line should be:
;;; fromuser=35129898hk
fromdomain=s2hkbntel.net
context=from-hkbn
canreinvite=no
insecure=very
disallow=all
; delete one of the two lines according to your bandwidth
allow=alaw ; if you have high incoming & outgoing bandwidth; i.e. > 128 kps
allow=g729 ; if you have low incoming & outgoing bandwidth; i.e. < 128 kps
dtmfmode=rfc2833
nat=yes
extensions.conf
[from-sip]
;;; Default context for all incoming SIP calls without a specific context definition
exten => _X.,1,Congestion
[from-hkbn]
;;; Incoming calls enter into this context
;;; I'll configure it to start the EchoTest
exten => 35129898,1,Answer
exten => 35129898,2,NoOp(==> ${TIMESTAMP}: Starting EchoTest for ${CALLERIDNUM})
exten => 35129898,3,Wait(2)
exten => 35129898,4,Playback(demo-echotest)
exten => 35129898,5,Echo
exten => 35129898,6,Playback(demo-echodone)
exten => 35129898,7,NoOp(==> ${TIMESTAMP}: Ending EchoTest for ${CALLERIDNUM})
exten => 35129898,8,Hangup
[default]
;;; Call out to the HK Observatory using HKBN
exten => 1878200,1,Dial(SIP/1878200@s2hkbntel.net)
/etc/hosts
203.80.89.135 s2hkbntel.net s21.hkbntel.net
You need the above entry in your /etc/hosts since HKBN has not created a DNS domain by the name of s2hkbntel.net. As a result, you need to have this entry in order for Asterisk to figure out which host to send your calls to and from which host calls should be accepted.
2b using at least 2 SIP Proxies
It has come to my attention that some "2b" subscribers have been moved to another SIP Proxy server. As a result, some subscribers cannot use s21.hkbntel.net as their SIP Proxy. The most obvious sign that you have been moved off of s21.hkbntel.net is if you can no longer REGISTER your presence with their SIP Proxy.To see verify your account was moved to the other SIP Proxy, enable SIP debugging for the 203.80.89.135 peer:
CLI> sip debug ip 203.80.89.135
If you see something like:
Sip read:
SIP/2.0 301 Moved Permanently
t: <sip:35129898@s2hkbntel.net>;tag=922074415
f: <sip:35129898@s2hkbntel.net>;tag=ec3f4cef5aa1376bo1
i: 46ccadff-b8c4c99b@192.168.1.102
CSeq: 136 REGISTER
v: SIP/2.0/UDP 169.129.0.3:5061;rport;branch=z9hG4bK-75923633
m: <sip:s2hkbntel.net:5060;maddr=203.80.89.139>
k: com.nortelnetworks.firewall,p-3rdpartycontrol,nosec
l: 0
9 headers, 0 lines
(Use "sip no debug" to turn off the debugging information.)
If you see the "301 Moved Permanently" SIP response, then that means HKBN has moved your account to another SIP Proxy besides s21.hkbntel.net. The new SIP Proxy you should use is listed in the "m:" line. The IP address after the "maddr=" is the new SIP Proxy. The IP address 203.80.89.139 corresponds to the hostname: s22.hkbntel.net. You will need to edit the /etc/hosts file and change the line:
203.80.89.135 s2hkbntel.net s21.hkbntel.net
to
203.80.89.139 s2hkbntel.net s22.hkbntel.net
I followed the procedure above but couldn't get Asterisk to register with HKBN 2B, after capturing traffic of the Windows client, I discovered that the client appends the characters "hk" to the end of my username:
By changing:
register => 35964261:password@s2hkbntel.net:5060/35964261
to
register => 35964261hk:password@s2hkbntel.net:5060/35964261 ;; Note the string "hk"
It now registers and I can take incoming calls on that number. I have not looked at outgoing calls, but if it fails — try changing the username.
For new user of HKBN 2b around and after Feb 2006, the username is no longer just the phone number anymore. It requires addition two characters hk appended at the end in order to work. -rcc 3/10/2006
2b's Proxy registration quirks
From my tests, it appears that the (Nortel?) Proxy/Registrar used by HKBN's 2b service presents the following problems:
1. The SIP URI of the REGISTER message must contain the domain name s2hkbntel.net, or else the message is rejected with status "403 - registrations to foreigndomains are forbidden" . This is problematic with Asterisk because it requires in sip.conf a "register" command containing "@s2hkbntel.net", and that same domain name is also used by asterisk to get the IP address of the Proxy/Registrar. Unfortunately, HKBN did not define an 'A' record for it, so the DNS resolution fails... Recent versions of Asterisk allow the "/etc/hosts" workaround described by chandave, but older versions (like the 1.0.7) apparently do not use the system resolver, and therefore ignore entries in /etc/hosts... Luckily that Proxy/Regstrar appears to support third-party registrations, so I took the "register" line out of sip.conf and now I rely upon the utility sipsak (see below).
2. The Proxy/Registrar does not allow multiple registrations with different contacts for the same user (resulting in new registrations rejected with status "403 LR1 - Login limit exceeded"), and:
3. The Proxy/Registrar doesn't seem to expire the registrations according to the "Expires:" header in the request.
The combination of 2. and 3. may create problems to clients with dynamic and often changing IP address. If a registration fails, the client should unregister all the previous contacts for that user. The following "HKBNregister" shell script, run every two minutes by a cron job on the same machine where Asterisk runs, does precisely this: first it gets the current external IP address from the output of "ipconfig ppp0" (my box also acts as router); then, using sipsak, it tries to register using as contact that IP address, and if the request fails it unregisters any existing contact (-C '*') and then it repeats the registration request (which usually succeeds):
#!/bin/sh
USR=....
PWD=....
OUR_IP="$(ifconfig ppp0 | sed -n -e 's/.*inet addr:\([.0-9]*\).*/\1/p')"
OUR_URI="sip:${USR}@$OUR_IP:5060"
HKBN_URI="sip:${USR}hk@s2hkbntel.net"
HKBN_HOST='s21.hkbntel.net'
if ! { sipsak -U -x 300 -C $OUR_URI -s $HKBN_URI -a ${PWD} -p $HKBN_HOST ; }; then
sleep 1 # seems to be necessary...
sipsak -U -x 0 -C '*' -s $HKBN_URI -a ${PWD} -p $HKBN_HOST
sipsak -U -x 300 -C $OUR_URI -s $HKBN_URI -a ${PWD} -p $HKBN_HOST
fi
USR=....
PWD=....
OUR_IP="$(ifconfig ppp0 | sed -n -e 's/.*inet addr:\([.0-9]*\).*/\1/p')"
OUR_URI="sip:${USR}@$OUR_IP:5060"
HKBN_URI="sip:${USR}hk@s2hkbntel.net"
HKBN_HOST='s21.hkbntel.net'
if ! { sipsak -U -x 300 -C $OUR_URI -s $HKBN_URI -a ${PWD} -p $HKBN_HOST ; }; then
sleep 1 # seems to be necessary...
sipsak -U -x 0 -C '*' -s $HKBN_URI -a ${PWD} -p $HKBN_HOST
sipsak -U -x 300 -C $OUR_URI -s $HKBN_URI -a ${PWD} -p $HKBN_HOST
fi
For sipsak, see: http://sipsak.org/ ; under OpenWRT, the installation is as simple as "ipkg install sipsak".
Enzo, 4 Nov 2006
See also
- Asterisk | Tips & Tricks | FAQ

Comments
333Re: Setup HKBN 2B in Nokia N95
STEP 1
Go to Tools / Settings / Connection / SIP settings. Create the following profile
Profile Name: (whatever)
Service Profile (IETF)
Access point: (your WLAN AP name)
Public user name: (user@s2hkbntel.net)
Use Compression: No
Registration: "Always on "
Use Security: No
STEP 2
You do not need to enter Proxy Server settings
Proxy Server Address: none
Registrar Server:none
Realm: none
User Name: none
STEP 3
Enter the following for Registrar Server settings
Registrar Server Address (s21.hkbntel.net)
Realm (s2hkbntel.net)
User Name (user)+hk
Password (password)
Transport Type (UDP/ AUTO)
Port (5060)
333Setup HKBN 2B in Nokia N95
333HKBN 2B Alternative
From only $99 HKD / $16.7 USD per month with 1 channel for unlimited incoming and outgoing calls + 1 Free HK DID 36xx-xxxx.
H323 / SIP supported with a wide ranges of codec from G711, G729, G723 etc.
And best of all we fully support asterisk and have a support team 24/7 for any support request.
For more info please visit telehk.net
333New Version of Asterisk
333Re: Is G.729 codec supported on 2b?
333DTMF 2833 not working with 2b
Any idea?
Ron
333DTMF 2833 not working with 2b
Any idea?
Ron
333Linksys WIP330 setup for HKBN 2B
Proxy IP : s2hkbntel
Proxy Port : 5060
Register Proxy IP : s2hkbntel
Register Proxy Port : 5060
OutBound Proxy IP : 203.80.89.139
OutBound Proxy Port : 5060
phone number : xxxxxxxxhk
User Name : xxxxxxxxhk
password : xxxxxx
Payload Type : G.711a, G.711u, G.729
Packet size : small
DTMF : Disable
VDP Port : 5060
RTP : 2070
The wireless in my home is also the Linksys & firewall is turn OFF
Now the phone seem to be registered to HKBN because the phone is show READY. but I can not make call and recive any call.
can anyone help my make it work.......
333Linksys WIP330 setup for HKBN 2B
Proxy IP : s2hkbntel
Proxy Port : 5060
Register Proxy IP : s2hkbntel
Register Proxy Port : 5060
OutBound Proxy IP : 203.80.89.139
OutBound Proxy Port : 5060
phone number : xxxxxxxxhk
User Name : xxxxxxxxhk
password : xxxxxx
Payload Type : G.711a, G.711u, G.729
Packet size : small
DTMF : Disable
VDP Port : 5060
RTP : 2070
The wireless in my home is also the Linksys & firewall is turn OFF
Now the phone seem to be registered to HKBN because the phone is show READY. but I can not make call and recive any call.
can anyone help my make it work.......
333Re: Is G.729 codec supported on 2b?