Awesome post title… anyway,
This is how I built a powerful Wi-Fi ADSL router, using my ALIX2D3 (previously running PFsense), a spare USB ADSL modem (Trust MD-3100) and a CM9 atheros-based miniPCI card.
Requirements
- ADSL modem (Conexant based for this howto)
- Average Linux knowledge
- vi editor familiarity
- USB CF card reader
Installing OpenWrt on CF card for ALIX boards
Boot your favourite Linux distribution. If you don’t have one try Ubuntu LiveCD: it loads in RAM and leave you data untouched.
Plug your CF card in your USB CF reader, and plug it in your USB connector. If your CF card isn’t formatted, your Linux may auto-mount the card’s partitions; if so, unmount them.
Type in terminal as root (may need su or sudo command):
fdisk -l
In the list of disks shown, identify your CF card and write down its name, the device size should help you (tip: assuming /dev/sda as your first sata disk, CF card should be named /dev/sdb).
Now download from here the 8.09.1 (lastest at the time of writing) version of OpenWrt x86 image.
All we need to do now, is to copy the image over the CF card.
WARNING: if you use the wrong device name for the next command, you may wipe out all your hard disk data.
Assuming your CF card device name /dev/sdX type this:
dd if=openwrt-x86-ext2.image of=/dev/sdX
Wait some time, and the command should end printing a report of written blocks. Now start GParted or your favourite partition editor, and grow the ext2 partition of your card up to fill the empty space.
Installing LuCI or X-Wrt web interface
OK, it is pretty useless for what we’re doing, but with a 1GB CF card, why not waste some space for a cool web interface??? Choose one of the following:
#1 LuCI:
opkg update opkg install luci-admin-full
And then add all the luci-app-*** packages you want to simplify your applications management.
#2 X-Wrt:
echo "src X-Wrt http://downloads.x-wrt.org/xwrt/kamikaze/8.09/x86/packages" >> /etc/opkg.conf opkg update opkg remove -recursive luci-* //NOTE: only if you have previously installed LuCI opkg install webif
Configuring ADSL modem
Install needed USB kernel modules:
opkg update opkg install kmod-usb-atm-cxacru kmod-usb2 kmod-usb-uhci
Download and put the ADSL modem firmware (cxacru-fw.bin) in /lib/firmware/.
Plug in the USB modem, and type:
dmesg | tail
Keep checking the output of this command, until you’ll get the “ADSL Line: up” state:
cxacru 1-1:1.0: receive of cm 0x90 failed (-104) cxacru 1-1:1.0: found firmware cxacru-fw.bin ATM dev 0: ADSL state: stopped ATM dev 0: ADSL line: down ATM dev 0: ADSL state: running ATM dev 0: ADSL line: initializing ATM dev 0: ADSL line: down ATM dev 0: ADSL line: attempting to activate ATM dev 0: ADSL line: down ATM dev 0: ADSL line: attempting to activate ATM dev 0: ADSL line: training ATM dev 0: ADSL line: attempting to activate ATM dev 0: ADSL line: training ATM dev 0: ADSL line: channel analysis ATM dev 0: ADSL line: up (7584 kb/s down | 480 kb/s up)
Configuring WAN interface
Now we’ll set up the WAN using the ppp0 interface that will be created by pppd.
The following configuration works for my ISP (Telecom Italia) edit it with your ISP parametes.
uci set network.wan=interface uci set network.wan.proto=pppoa uci set network.wan.ifname=ppp0 uci set network.wan.encaps=vc uci set network.wan.vpi=8 uci set network.wan.vci=35 uci set network.wan.username=aliceadsl uci set network.wan.password=aliceadsl uci set network.wan.peerdns=1 uci commit network /etc/init.d/network restart
Now the ppp0 interface should come up and you’ll be able to reach internet.
ADSL sync wait script
The only problem is that on startup, before upping the WAN interface, the system must wait for the ADSL line to come up. I solved this problem with this simple script that start on boot, wait for ADSL sync and then restart the OpenWrt network. It is a modified version of the one you find in Reference #2 at the bottom of this post.
Create the file /etc/init.d/adsl and paste this script in it:
#!/bin/sh /etc/rc.common # ADSL start script START=98 boot() { exsist=0 sync=0 until [[ -e /proc/net/atm/cxacru\:0 ]] do if [[ $exsist = '0' ]] then echo "InitAdsl Waiting cxacru.fw loading" exsist=1 fi done echo "InitAdsl Firmware loaded" end=0 while [[ $end = '0' ]] do if [[ $sync = '0' ]] then echo "InitAdsl Waiting sync" sync=1 fi if [[ `grep Line /proc/net/atm/cxacru\\:0 | cut -d' ' -f2` = 'up' ]] then end=1 /etc/init.d/network restart echo "InitAdsl Sync done" fi done }
Save the file and type on terminal:
/etc/init.d/adsl enable
Now reboot your router. Everything should work automagically. My router in 3 minutes is connected and providing natted internet service to the dhcp clients.
Configuring wireless interface
TODO!
References
- LuCI Reference
- Modem sync wait script from MandrakeItalia.org
- Various infos taken from Paolo Minazzi’s page
- PC Engines’ ALIX boars
it was very interesting to read.
I want to quote your post in my blog. It can?
And you et an account on Twitter?
Sure you can!
My twitter account is maracne.
Thanks for your compliments!