2012-04-03

WR1043ND to OpenWRT

Complie personal build

First, I downloaded OpenWRT from official website and flushed it, it works pretty good. But there is a very important problem. OpenWRT does not support channel 12 and 13. These two channels are not allowed to be used in US. But, I am living in EU, it is no sense to waste two channels if there are more then 10 neighbors' wireless networks around you. As OpenWRT has an agreement with Atheros, they cannot provide pre-build bin file which support channel 12 and 13. So, I have to build my own one to let OpenWRT respect user's setting. On ubuntu/debian system install:
  bash$ sudo apt-get install subversion build-essential libncurses5-dev zlib1g-dev gawk flex quilt git-core
Create a folder to hold source files for compile:
  bash$ mkdir ~/OpenWRT
  bash$ cd OpenWRT
  bash$ svn co svn://svn.openwrt.org/openwrt/trunk/
  bash$ cd trunk
The respository can be found at https://dev.openwrt.org/wiki/GetSource. Option packages can be enabled in feeds.conf.default file which located at the root folder of the repository. Next, in order to update feeds after changing the sources, we need to run:
  bash$ scripts/feeds update -a
  bash$ scripts/feeds install -a

Then "scrips/feeds search xxx" can be used to search package and "scripts/feeds install xxx" can be used to install packages. The dependency will automatically be resolved by feed script.

To build rom for my router. I need to specify the setting:
  bash$ menuconfig
    Target System: Atheros AR71xx/AR7240/AR913X
    Target Profile: TP-LINK TL-WR1043ND v1
    Check the setting in Kernel modules-->Wireless Drivers-->kmod-ath-->configuration
  $make -j 3

First Login

After compile, file with name "openwrt-ar71xx-tl-wr1043nd-v1-squashfs-factory.bin" can be found in output folder. This is the file that need to flash on a factory router. Another one with name "openwrt-ar71xx-tl-wr1043nd-v1-squashfs-sysupgrade.bin" can be used to update router which already installed OpenWRT. The default status of a freshly instelled router is:
  • The internal interface lan and the wireless interface/interfaces wlan0 / wlan1 are bridged together to br-lan
  • wifi is disabled
  • the IP address of the internal interface/bridge of the OpenWrt-device is 192.168.1.1/24
  • dnsmasq is running; it allocates IP addresses in the range of 192.168.1.100 to .250 on the internal interface to connected hosts
  • dropbear does not accept connections
  • telnet daemon is running on standard port (23)
The first thing we need to do is to telnet to it and change the password. run command:
telnet 192.168.1.1
to connect to the router and:
root@openwrt:~$ passwd
Changing password for root
New password:
Retype password:
Password for root changed by root
root@openwrt:~$
after you set a password the telnet daemon will be disabled, type exit into the prompt.
without reboot, SSH is now available; so is HTTPS if the WebUI (LuCI) is installed with it's TLS-modules.
login again with ssh root@192.168.1.1

Install luci

Luci is a very easy to use GUI for OpenWRT. It can be installed from repository (other method). OpenWRT repository management system is similar to debian's dpkg, instead, it named opkg. As apt-get, the first thing to do is to retrieve the current list of available packages in the repository:
  opkg update
For a full LuCi installation without HTTPS suport:
  opkg install luci

Start LuCi(uHTTPd) server

Enable automatic start at boot and manually start the LuCi server with commands:
  
  /etc/init.d/uhttpd enable
  /etc/init.d/uhttpd start
After this, it is able to connect the router with web browser at http://192.168.1.1
uHTTPd can be configured, but it is not required.

Install required modules for WiFi

    opkg update
    opkg install kmod-ath9k wpad-mini
Wifi will be ready after reboot.

Install USB/HDD

To enable mass storage capability:

  root@OpenWrt:~# opkg install kmod-usb-storage
After that we can enable file system that we want to use. For example, we want to enable ext4 support:
  root@OpenWrt:~# opkg install kmod-fs-ext4
Now we can use blkid to list all avaiable disk. In my case, I got:
  root@OpenWrt:~# blkid
  /dev/sda1: UUID="0737-3F5F"
Ref:
  • http://knowhow.bart.prokop.name/install/openwrt/wr1043nd
  • http://blog.philippklaus.de/2011/04/openwrt-on-a-tp-link-tl-wr1043nd-gigabit-router

Setup DNS and DHCP

ref: http://wiki.openwrt.org/doc/uci/dhcp

Setup DDNS with ddns-scripts

Web interface can be used. But, in order to save more space, I decide to go to scripts. Check: http://wiki.openwrt.org/doc/howto/ddns.client

Install ddns-scripts package

  root@OpenWrt:~# opkg install ddns-scripts
The configuration is stored in /etc/config/ddns. At least one section has to be enabled to active ddns Enable the setting:
  root@OpenWrt:~# ACTION=ifup INTERFACE=wan /sbin/hotplug-call iface

WOL

I use my android phone to send wol message to my nas server. The name of the application is "Wol Wake On Lan Wan". I have already set up WOL function on my NAS. Here, we going to focus on Wol configuration on openwrt. 1. Add forwarding setting in firewall (/etc/config/firewall):
  config 'redirect'
    option '_name' 'wol' #name of this redirect 
    option 'src' 'wan' # message from internet
    option 'proto' 'udp' # wol package is udp
    option 'src_dport' '9' # wol port is set to 9
    option 'dest_ip' '192.168.0.2' # IP of NAS server
    option 'dest_port' '9'
    option 'target' 'DNAT' # I am using dynamic NAT
    option 'dest' 'lan' # of cause, my NAS is in my LAN
2. The next step is to add a binding between IP address and MAC address. Following ip command should be used to ask OpenWRT to remember ARP setting unless manual change or reboot. In order to keep this setting after rebooting. We need to add it to /etc/rc.local. So it will be invoked each time the router rebooted.
 
  ip neigh add 192.168.0.2 lladdr 1c:6f:65:b7:fe:b1 nud permanent dev br-lan
This command bind ip address 192.168.0.2 to MAC address 1c:6f:65:b7:fe:b1 and this is a permanent mapping to interface br-lan. If ip command is not installed yet. Run:
 opkg update
  opkg install ip
This command should be run manually, if we don't want to reboot the router. After this, command arp -a can be used to verify the mapping. Now the WOW should be ready.

3 comments:

  1. Hello, before menuconfig you miss make. Thx. J.

    ReplyDelete
  2. Thank you for share
    ----------------------------------
    http://www.easyzonecorp.net - cloud radius billing for mikrotik hotspot

    ReplyDelete