Advolex - Kein schöner Leben

Ein privates Blog, völlig ohne Allgemeininteresse.

Name: Advolex
Location: Lidingö, Sweden

Sunday, March 16, 2008

Installing OpenWRT with UMTS support

Summary with some comments, on installing and setting up OpenWRT with UMTS support

Step by step; In simplified English, by mnordlin

Install OpenWRT Kamikaze 7.09

1. Download firmware image from http://downloads.openwrt.org/kamikaze/7.09/brcm-2.4/openwrt-brcm-2.4-squashfs.trx (provided you already have kamikaze installed - install the corresponding bin file otherwise)
2. Copy firmware to /tmp folder on device.
3. Execute
root@OpenWrt:~# mtd -r write openwrt-brcm-2.4-squashfs.trx linux
4. Wait until connection breaks, which happens when installation reboots
5. Open a command window, start -> run -> cmd.
6. Attach an ethernet cable between your PC and device (you won't have access to WLAN until later on).
7. C:\Documents and Settings\Mikael>telnet 192.168.1.1 [enter]
8. Get your personal public key or create a key pair. You will probably find PUTTYgen (included with WinSCP) useful for generating your RSA key pair and pasting your public key to device in next step. The secret key will be required later on for logging in to the device.
9. Execute in telnet window, using copy and paste,
root@OpenWrt:~# echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAtQl8uscy3rjAbNBdL2ATUKfHCJHB+Zh7V5aTjBLoJ7F
AOw1fnCCpzWi2yUsqbjrzVIO6tFsPODS3PRc0my9ghSxO9itmwOe0kKLYc8blNf9kcQ27upSyf
Ff5jhE5AwyqEpzmc26FPwj4Zhip+aWg1ZLaEUn/WLHLEuXHPA9lRRgtlYHqgT7Ap3D/lZ/9Rd
4zCxTKAshzjO5fEBAXyOMADYJ1G9IIaKDHkHGtb981Sraxk9f+wMbOBuyvOGJKKXHuX04X
V7dmY87AhmAaRwEPeS0gGqoEkDMeALqyt1dYKqZ+Tv58UAPakS6nM9YhOGMMY5sCWM
m/bS3XQFbrv+2qWQ== rsa-key-20080313' > /etc/dropbear/authorized_keys
(be sure to use your own public key - the one in the example is a 2048 bits RSA key in PUTTY format for SSH-2, created by mnordlin)
10. Execute
root@OpenWrt:~# cat /etc/config/dropbear | sed -e "s/'on'/'off'/" > /etc/config/dropbear
(or simply change the line to "option PasswordAuth 'off'", replacing 'on' to 'off')
11. Execute
root@OpenWrt:~# rm /etc/rc.d/S50telnet
12. Check your public key was entered correctly by displaying it, execute
root@OpenWrt:~# dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key
13. Check that ssh works (dropbear on device), and reboot. Telnet access is now disabled. The only means of accessing device is with ssh (SCP as in WinSCP), using your private key.
14. Enable WiFi/WLAN by adding '#' in front of the line 'option disabled 1', or simply removing the whole line, in /etc/config/wireless
15. Add credentials for WiFi security.
Use WPA-PSK by changing 'option encryption' from 'none' to 'psk' and adding "option key '12345678'".
Change 'OpenWrt' to 'WRT54G3G' while you're at it, should you ever get a second router.
16. Your next router won't be a WRT54G3G.
Change the hostname of the device in /etc/config/system from OpenWRT to WRT54G3G.
The command line will remain as OpenWRT until next reboot, however.

Enabling 3G/UMTS

17. Install the PCMCIA drivers; kmod-pcmcia-core and pcmcia-cs:
Copy the drivers from openwrt.org to device /tmp, then execute the ipkg install commands:
root@OpenWrt:~# ipkg install pcmcia-cs_3.2.8-1_mipsel.ipk
root@OpenWrt:~# ipkg install kmod-pcmcia-core_2.4.34-brcm-1_mipsel.ipk

18. Reboot the device without the Huawei E600.

19. Check that CardBus Controller installed fine
root@OpenWrt:~# cardctl status
Output should look like:
Socket 0:
no card

20. Insert the Huawei E600 into device and check CardBus Controller status again. Output now should look like:
Socket 0:
3.3V CardBus card
function 0: [ready]
function 1: [ready]

21. Install USB support: kmod-usb-core, kmod-usb-serial, kmod-usb-ohci (for SlugOS, use 'kernel-module-usbserial').
root@OpenWrt:~# ipkg install kmod-usb-core_2.4.34-brcm-1_mipsel.ipk
root@OpenWrt:~# ipkg install kmod-usb-serial_2.4.34-brcm-1_mipsel.ipk
root@OpenWrt:~# ipkg install kmod-usb-ohci_2.4.34-brcm-1_mipsel.ipk

22. Install 3G/UMTS support (for dialup PPP): chat, comgt.
root@OpenWrt:~# ipkg install chat_2.4.3-8_mipsel.ipk
root@OpenWrt:~# ipkg install comgt_0.32-1_mipsel.ipk

23. Modífy the WAN section of “/etc/config/network” to read:
#### WAN configuration
config interface wan
option ifname 'ppp0'
option proto '3g'
option device '/dev/usb/tts/0'
option apn 'internet.tele2.se'
option pincode '1234' (or what you have here)
option dns "130.244.127.161 130.244.127.169"

24. Modify the LAN section by adding the following both lines.
option gateway 192.168.1.1

25. Start (and optionally time) the wan interface:
root@OpenWrt:~# time ifup wan
Wireless WAN (WWAN as it was called in whiterussian) is now started. Output should look like:
ifconfig: SIOCGIFFLAGS: No such device
Trying to set PIN
PIN set successfully
Trying to set mode
Error setting WWAN mode!
real 0m 7.22s
user 0m 0.69s
sys 0m 1.17s

Update wget

26. Update wget (to avoid the segmentation fault bug)
root@OpenWrt:~# ipkg update
root@OpenWrt:~# ipkg -force-overwrite install wget

Setup DDNS

27. Create the file /etc/ppp/ip-up.d/S01dyndns (and don't forget to chmod it executable; i e 0x0755) with the following content:
#!/bin/sh
USER="user"
PASS="pass"
DOMAIN="domain.ath.cx"
registered=$(nslookup $DOMAIN|sed 's/[^0-9. ]//g'|tail -n1|sed -e's/ [0-9.]*//2' -e's/ *//')
current=$(wget -O - http://checkip.dyndns.org|sed 's/[^0-9.]//g')
[ "$current" != "$registered" ] && {
wget -O /dev/null http://$USER:$PASS@members.dyndns.org/nic/update?hostname=$DOMAIN &&
registered=$current
}
sleep 3
newip=$(wget -O - http://checkip.dyndns.org|sed s/[^0-9.]//g)
newdns=$(nslookup $DOMAIN|sed 's/[^0-9. ]//g'|tail -n1|sed -e's/ [0-9.]*//2' -e's/ *//')
echo "Set ${newip} (DNS: ${newdns}), had ${current} (DNS: ${registered})" \
| /usr/bin/logger -t ddupd

28. After a reboot, check DynDNS by running
root@OpenWrt:~#nslookup gashaga.ath.cx (<- your domain goes here)

29. Compare the ip address with the ip for ppp0 by running
root@OpenWrt:~#ifconfig
If the numbers are equal, all is fine.

Open iptables for incoming ssh

30. To open up the firewall to allow incoming connections on port 22 (the ssh port), add the following line to “/etc/config/firewall”:
accept:proto=tcp dport=22

A Masquerading SIP Proxy: siproxd

31. Install siproxd according to Hias in http://forum.openwrt.org/viewtopic.php?id=9397
Since you're running OpenWrt 7.09 (aka Kamikaze) your bridged LAN is named br-lan (br0 was whiterussian). ppp0 remains, though, even if you start your Internet interface by 'ifup wan'. You can check the names with 'ifconfig', which you used in step 29 above.

32. Change settings from 'transparent SIP proxy' to 'GS BT-100 behind NAT router running siproxd' from
http://apocalyptech.com/linux/sipnat/siproxd-pdf.htm.

QoS: L7/SIP

33. Install ipkg install qos-scripts

34. Setup QoS according to http://www.voip-forum.se/forum/showthread.php?t=601 and install sip.pat level7-filter from
http://l7-filter.sourceforge.net/layer7-protocols/protocols/sip.pat

References:

A. http://josefsson.org/grisslan/internet.html
B. http://wiki.openwrt.org/OpenWrtDocs/KamikazeConfiguration
C. http://wiki.openwrt.org/DDNSHowTo
D. http://forum.openwrt.org/viewtopic.php?pid=57925
E. http://forum.openwrt.org/viewtopic.php?id=9397
F. http://apocalyptech.com/linux/sipnat/siproxd-pdf.html
G. http://www.voip-forum.se/forum/showthread.php?t=601
H. http://l7-filter.sourceforge.net/layer7-protocols/protocols/sip.pat

Labels: , , , , ,