OpenWRT on TP-Link TL-WR740N

As i was going back home this summer, i thought – why not do some applied networking at home? After playing with the Asus RT-N16 router and OpenWRT in 2nd semester i thought that i should buy one of the cheapest OpenWRT-comaptible routers and start networking.

Why one of the cheapest? I just wanted something that will work and suffice for a small home network and it came out of my summer-budget so i had to make some priorities. 😀

After a short battle between TP-Link TL-WR740N and Dlink Dir-600 i have decided on the TP-Link. I’m still not sure why.(maybe because of the better compatibilty with OpenWRT) I got it for 82 Lei , that’s aproximately 20 euros from here.

I found this page and it went pretty smooth. I looked on the back of the router and saw that i have a v4. I’ve downloaded the trunk image from OpenWRTs download section, that’s here. I flashed it through the factory web interface in Firefox.

After flashing it i had in mind to :

  • install a graphical web interface (Luci)
  • set up my PPPoE connection
  • set up dynamic dns so i can access the router through a hostname because my ip is dynamic
  • set up wake-on-lan for my desktop-pc, so i can remotely use it anytime i want, without keeping it up 24/7
  • set up some proper firewall rules

I connected to the router through telnet and set a root password to disable telnet and enabled ssh

telnet 192.168.1.1

passwd

(input password twice)

exit

ssh root@192.168.1.1

Luci

I manually downloaded dependencies for Luci because i had no internet access (PPPoE had to be configured differently and i didn’t know how through the command line, google didn’t help me to much). This took me a while… I had to download each one of these :

uhttpd * uhttpd-mod-lua * luci-theme-openwrt * luci-theme-base * luci-app-firewall * luci-proto-core * luci-proto-ppp * luci-mod-admin-full * luci-mod-admin-core * luci-lib-web * luci-lib-core * lua * libuci-lua * libubus-lua * luci-lib-sys * luci-lib-nixio * luci-lib-core * luci-sgi-cgi * luci-lib-lmo *luci-proto-core * luci-i18n-english *  luci-lib-ipkg * libiwinfo-lua * libiwinfo * liblua * lua *

And scp them in the router. It took even more when i realised i didn’t had any space left. Anyway, after that i had to reboot and enable uhttpd:

reboot

/etc/init.d/uhttpd enable
/etc/init.d/uhttpd start

(the screenshot was made some time after i installed Luci, so thats why you see that uptime of 27 days ; so are the other screenshots)

Note to self – NEXT TIME, COMPILE YOUR OWN IMAGE!

The PPPoE connection:

– go to luci web interface, login and look for Network -> interfaces -> edit WAN -> switch from DHCP(default) to PPPoE

– after this i edited the /etc/config/network file so that it would look like this:

config interface ‘wan’

option ifname ‘eth1’
option _orig_ifname ‘eth1’
option _orig_bridge ‘false’
option proto ‘pppoe’
option username ‘ISP_USERNAME’
option password ‘ISP_PASSWORD’
option keepalive 10
option ppp_redial persist
option defaultroute 1

Dynamic DNS

After reading this i started setting up dynamic dns:

opkg install luci-app-ddns
opkg install ddns-scripts

Checked for the services tab in Luci and it was there. In case it isn’t just reboot the router.

The config file is : /etc/config/ddns

You can check if your dyndns service is supported in here : /usr/lib/ddns/services

This script is being ran to update : /usr/lib/ddns/dynamic_dns_updater.sh

Thanks to this i scheldued the update-script to run every 15 minutes, because for some strange reason, it didn’t update itself :

*/15 * * * * /usr/lib/ddns/./dynamic_dns_updater.sh myddns > /dev/null

Now it works!

Wake-on-lan

I was so eager to see how this works and now i had the chance to see it. I installed etherwake , change some power options in my pcs bios (i enabled it to be powered by PCI devices)

opkg install etherwake

etherwake MAC

It works!

An alternative to etherwake would be wol:

opkg install wol
nano /etc/config/wol

config wol-target

option mac ‘xx:xx:xx:xx:xx:xx’

option broadcast ‘192.168.1.255’
option enabled ‘1’

/etc/init.d/wol start

Other stuff

1. Specs

Atheros AR7240@400MHz 32MiB 4MiB 4 x 1 mod Yes No

CPU – Atheros AR9330 rev 1

RAM – 32MB

FLASH – 4MB

SLOTS – 4 LAN , 1 WAN

BUTTONS – ON/OFF , reset

ANTENNA – 1, NOT DETACHABLE

2. Strange repetitive log in syslog (logread) :

daemon.warn dnsmasq-dhcp[5945]: DHCP packet received on eth1 which has no address

Found the answer here and edited etc/config/dhcp so that it would look like in the forum post:
config ‘dnsmasq’

    …
    …
    list ‘notinterface’ ‘eth1’

And then i restarted dnsmasq

/etc/init.d/dnsmasq restart

3. Accesing the router from WAN

When the router is accesed from the outside(WAN) you will get a “rejected request from rfc1918 to public … ” –> thats because of the uhttpd config.

The listening address must be changed to your local one (in most cases – 192.168.1.1). You have to edit the config file so that it would look like below:

nano /etc/config/uhttpd

# HTTP listen addresses, multiple allowed
list listen_http 192.168.1.1:80

# list listen_http [::]:80

# HTTPS listen addresses, multiple allowed
list listen_https 192.168.1.1:443

# list listen_https [::]:443