TPLink – WR703N… The caravan router

So, now that we’ve purchased our first caravan and progressed from caping to glamping with all the mod cons (Well the ones I can afford) it was decided between the brains trust at work, that being able to take away the entire movie library so the kids could watch anything they liked as we drove along, or if heaven forbid bad weather hits us, it will be just like being at home.

So what do we need this magical box to do

1. Provide wifi access whilst travailing in the vehicle as well as when camped

2. Provide windows file sharing of media to allow devices running xvmc or other software to access the media

3. Possibly run some sort of DLNA type server to stream media to devices that can’t access SMB shares directly

4. Possibly provide a bridge between my phones next-g connection and wifi only devices such as iPads/iPods (Not implemented yet as not required)

Things required:

* OpenWRT Firmware (Atitude Adjustment at the time of writing)

* TP-Link WR703N

* USB HDD (To store both the routers O/S as well as media files)

* Ethernet Cable

* 1Amp Cigarette Power Adapter for the car

Lets get it done:

Pre-reqs:

Partition the HDD. 

For this you will need to create three separate partitions

  • 2 small 1GB partitions in EXT4 format
  • the rest of the drive should be partitioned as NTFS

The size of the ext4 partitions was chosen as this allowed ample room for messing around with openwrt, whilst when considering scale, a few gb out of a tb doesn’t really lend itself to being noticed.

NTFS was chosen as the other fs type as this will mean when the HDD is plugged into a windows machine to copy moves etc to it, the ext4 parts by default will be invisible and only the ntfs partition will be visible (Protection by obfuscation)

How you partition your drive is up to you, I used an existing linux box, however gparted can be downloaded and used to do it from a usb key.  Windows on its own doesn’t work as you can’t format ext4 partitions.  Once you get comfortable with it, you can actually do the partitioning with openwrt, this will not be covered in this guide.

The Main Event

Connect your computer to the 703N via ethernet as I don’t trust using wifi to do a firmware upgrade

The 703N will more than likely come pre-installed with Chinese language firmware.  So the first hurdle is trying to work out how to flash OpenWRT to the router in the first place.

So to do this we open http://192.168.1.1 in our favourite web browser

Click the very bottom option

LastOption

Then select the third option down

Thirdoption

Click the button labeled 1. and select the openwrt firmware you downloaded.  Then press the button i’ve labeled 2.

Upload

After a few minutes the file will be uploaded in the router, and it will begin to reboot.

On reboot you may need to statically set the ip address of your network card.  Configure them to match the settings I have listed here and your should be able to ping the router once its blue light stops flashing indicating it has booted up

Network

Now we need to setup a password to allow us to ssh into the router.

Open your browser and connect to the router at its default address (usually 192.168.1.1). Login using username root with an empty password.

Make sure your browser accepts (session) cookies. LuCI login fails if password is set and session cookies cannot be accessed.

Then click on the left in the top bar on Administration, then go to System in the bar underneath. A page to change the password is displayed.

Write your desired password into the field Password and repeat it in the field Confirmation. Finally click on Save & Apply.

Your password is set now.

Next we ssh into the router (on mac enter ssh root@192.168.1.1 into a terminal windows)(on windows again use Putty select SSH from the connection type and enter root@192.168.1.1 as the host) you will be asked to enter the password, type it in and press enter.

Now we’ve set the admin password and logged in via ssh its time to enable wifi. (Plagirised from the openwrt wiki)

vi /etc/config/network

then press i to enter insert mode

config interface ‘wan'
option ifname ‘wlan0'
option proto ‘dhcp'

now press esc and then enter :wq this will save and quit VI

now we need to configure our existing network

vi /etc/config/wireless

again enter insert mode by press i

now you need to enter the details that will match your existing wifi network to allow you to connect this box

config wifi-iface
option device radio0
option network wan
option mode sta
option ssid ‘’’yournetworksssid’''
option encyption psk
option key ‘’’yournetworkkeyhere’''

To configure other network types visit the page here for further reading.

now that we’ve connected our device to the internet its time to actually install some software.  The package monitor in openwrt is opkg.  Easy to use

so in our ssh sessions we type in:

opkg update

this will download a list of up to date packages ready for us to install

opkg install luci
/etc/init.d/uhttpd enable
/etc/initi.d/uhttpd start

You should now be able to visit 192.168.1.1 in your browser and be greeted with the OpenWRT main login page

this will give us a pretty web interface to do much of our configuration

now that we’ve install Luci we’ll also want to at this point install extroot.

EXTROOT essentially allows us to utilise space on another device such as a hdd or usb key and make it appear to the router as if it is its own internal flash rom.

EXTroot requires we get our USB HDD recognised .  Very simple to do.

#update available packages
opkg update
#Install needed filesystem support
opkg install kmod-usb-storage kmod-fs-ext4 block-mount

# Now to copy the required files to the usb hdd that will become our overlay

mkdir -p /mnt/sda1
mount /dev/sda1 /mnt/sda1
mkdir -p /tmp/cproot
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt/sda1 -xf -
umount /tmp/cproot
umount /mnt/sda1

Now we need to tell openwrt using stab how and where to mount the partition

vi /etc/config/fstab

make the following changes

#old
option target /home
option enabled 0
#new
option target /
option enabled 1

press the esc key and then press : and enter wq

now enter the following:

reboot

after rebooting the machine ssh back into the box and enter the following

df

you should see rootfs size now matches that of the partition we created

Thats it done.  Our router is now using the attached USB HDD as its main storage. If we boot the router without the HDD attached it will use its own internal flash as storage.  This essentially means we can have a failsafe configuration if we screw something up on the USB HDD, we remove the drive, reboot the router and BOOM we’re back in.

Now you can go ahead and install what ever you like to the drive.  For us thats samba, and in an upcoming project dlna for those that don’t utilise XBMC


opkg update
opkg install luci-app-samba block-mount nano fdisk ntfs-3g

Configure the samba mount points as required, sit back, grab a cold one and be done iwth it.

For the next project I’m looking at recompiling OpenWrt with the required packages already built in. I’ve had success building in most if not all the required apps just need to bundle config files to make setup alot more rapid should something go wrong in the future.