OpenWrt on TP-Link TL-WR941ND / TL-WR1043ND / TL-WDR3600 / TL-WDR4300

# 15.05

# flash tl-wr1043nd
URL=http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/openwrt-15.05.1-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin
wget ${URL} -P /tmp
scp /tmp/openwrt-15.05-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin root@192.168.1.111:/tmp/
ssh root@192.168.1.111
echo 3 > /proc/sys/vm/drop_caches
mtd -r write /tmp/openwrt-15.05.1-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin firmware

# flash tl-wdr4300
URL=http://downloads.openwrt.org/chaos_calmer/15.05.1/ar71xx/generic/openwrt-15.05.1-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bin
wget ${URL} -P /tmp
scp /tmp/openwrt-15.05.1-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bin root@192.168.1.111:/tmp
ssh root@192.168.1.1
mtd -r write /tmp/openwrt-15.05.1-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bin firmware

telnet 192.168.1.1

passwd

exit

TP-Link TL-WR1043ND OpenWrt

# OpenWrt Sysupgrade

#
# reset settings
#
# failsave

# load factory defaults
firstboot -y && reboot

#
# flash
#
# configure ip
echo "nameserver 192.168.1.5" > /etc/resolv.conf
ifconfig br-lan 192.168.1.111 up
route add default gw 192.168.1.5

# free memory
echo 3 > /proc/sys/vm/drop_caches

# download
cd /tmp
#wget -P /tmp
wget -P /tmp

# flash
#mtd -r write /tmp/openwrt-ar71xx-generic-tl-wr1043nd-v1-squashfs-factory.bin firmware
mtd -r write /tmp/openwrt-15.05-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bin firmware

#
# configure
#
telnet 192.168.1.1

# todo (automate)
passwd

# enable DHCP client on lan
# uci show network.lan
uci delete network.lan.ipaddr
uci delete network.lan.netmask
uci set network.lan.proto=dhcp
uci commit network

# remove old nameserver (TODO uci set ?)
echo "nameserver 192.168.1.5" > /etc/resolv.conf

# disable server on lan
# uci show | grep dhcp
uci set dhcp.lan.ignore=1
uci delete dhcp.lan.start
uci delete dhcp.lan.limit
uci delete dhcp.lan.leasetime
uci commit dhcp

reboot

#
# connect over ssh
#
ssh root@192.168.1.111

#
# install / deinstall applications
#
opkg update

# install
opkg install kmod-usb-storage kmod-fs-ext4 fdisk e2fsprogs
opkg install rsync
# opkg install wol
# opkg install etherwake

# deinstall
opkg remove ppp-mod-pppoe ppp kmod-pppoe kmod-pppox kmod-ppp

# OPTIONAL: remove webinterface
opkg remove "luci-*" #run multiple times
opkg remove uhttpd

#
# hostname
#
uci set system.@system[0].hostname=WlanUnten
uci commit

#
# configure ssh
#
[ ! -d ~/.ssh ] && mkdir ~/.ssh
chmod 600 ~/.ssh

# create private key
dropbearkey -t rsa -f ~/.ssh/id_rsa

# create public key
touch ~/.ssh/id_rsa.pub
dropbearkey -y -f ~/.ssh/id_rsa | grep "^ssh-rsa" >> ~/.ssh/id_rsa.pub

# copy public key to host
cat ~/.ssh/id_rsa.pub | ssh root@192.168.1.111 'cat >> /etc/dropbear/authorized_keys'

HOST=192.168.1.1
#scp ~/.ssh/id_rsa.pub root@${HOST}:/tmp/
#ssh root@${HOST} "cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys; rm /tmp/id_rsa.pub"
cat ~/.ssh/id_rsa.pub | ssh root@${HOST} 'cat >> /etc/dropbear/authorized_keys'

# test login with private key
ssh -i ~/.ssh/id_rsa root@${HOST}

# create alias
echo alias ssh=\"ssh -i /root/.ssh/id_rsa\" >> /etc/profile
echo alias rsync=\"rsync -e \'ssh -i /root/.ssh/id_rsa\'\" >> /etc/profile

# show all alias
alias

# create backup with rsync
mount /dev/sda1 /mnt
rsync -av --delete --exclude=dev/* --exclude=proc/* --exclude=sys/* --exclude=tmp/* --exclude=mnt/* --exclude=run/*
--exclude=media/* root@${HOST}:/ /mnt/${HOST}/
umount /mnt

# Links

#
# timezone
#

uci set system.@system[0].timezone=CET-1CEST,M3.5.0,M10.5.0/3
uci commit

#
# swap
#

opkg update
opkg install swap-utils

dd if=/dev/zero of=/mnt/swapfile bs=1M count=64

mkswap /mnt/swapfile
swapon /mnt/swapfile

#
# uci
#


#
# LEDs (dep)
#

# USB led works out of the box under OpenWrt Attitude Adjustment 12.09

echo 1 > /sys/devices/platform/leds-gpio/leds/tl-wr1043nd\:green\:usb/brightness

cat /etc/config/system

config 'led' 'usb_led'
option 'name' 'USB'
option 'sysfs' 'tl-wr1043nd:green:usb'
option 'trigger' 'usbdev'

set system.usb_led=led
set system.usb_led.name='USB'
set system.usb_led.sysfs='tl-wr1043nd:green:usb'
set system.usb_led.trigger='usbdev'
set system.usb_led.dev='1-1'
set system.usb_led.interval='50'
uci commit system

#
# cron
#

root@WlanUnten:/# cat /etc/crontabs/root
41 14 * * * /bin/mount /dev/sda1 /mnt/; /mnt/backup.sh /mnt/; /bin/umount /mnt
#

#
# wifi
#

#
# HDD
#
opkg install hd-idle
uci set hd-idle.@hd-idle[0].idle_time_interval=180
uci commit

#
# old / test
#
uci set dhcp.ignore=1

uci set wireless.wl0.country=DE

uci set network.lan.type=bridge
uci commit
reboot

uci set network.lan.ifname="eth0.0 eth0.1"
uci commit

uci set network.lan.peerdns=1

uci -P /var/state show network
uci -P /var/state show wireless

# set fixed ip
#uci set network.lan.ipaddr=192.168.1.111
#uci set network.lan.dns=192.168.1.5
#uci set network.lan.gateway=192.168.1.5
#uci commit network

# copy public key to OpenWrt
#
cat ~/.ssh/id_rsa.pub | ssh root@openwrt 'cat >> /etc/dropbear/authorized_keys'

###########################################################

#
# OLD
#

# neu

sed -i 's|192.168.1.1|192.168.2.254|g' /etc/config/network

# openvpn

Configure OpenWRT
# set ip on localhost
#sudo ifconfig eth0 192.168.1.100 up
dhclient eth0

# change password on web interfece

System > Admin Password

# ssh login to OpenWRT
ssh root@192.168.1.1

# configure ip network
vi /etc/config/network
config interface lan
option ipaddr 192.168.2.254

# reboot
reboot

# login again
ssh root@192.168.2.254

# install filesystems
opkg install kmod-usb2 kmod-usb-storage kmod-fs-vfat kmod-fs-ext2

# Wake-On-Lan (etherwake -i br-lan 00:11:22:33:44:55)
opkg install etherwake

# OPTIONAL: remove unused packages
opkg remove ppp-mod-pppoe
opkg remove ppp
opkg remove kmod-pppoe
opkg remove kmod-ppp

minicom
# ttyUSB0
opkg install kmod-usb-serial-ftdi minicom

# configure tty device
echo "pu port /dev/ttyUSB0" >> /etc/minirc.dfl

OpenWRT download

Buttons
mkdir -p /etc/hotplug.d/button
download 00-button
wget

WPS on OpenWRT

Update
opkg -verbosity=0 update
for PKG in $(opkg list-upgradable); do
opkg upgrade echo ${PKG}
done

Aircrack
opkg install wireless-tools aircrack-ng

Links
- TL-WDR4300 (128 MB RAM, 2x USB)
- TL-WR1043ND (32 MB RAM, 1x USB)
- TL-WR941ND (no USB)







http://wiki.openwrt.org/doc/howto/hardware.button?s[]=uci%20add