====== OpenWrt sur un Asus WL 500g Deluxe ======
Cette page regroupe diverses informations glanées auprès de différentes sources. Quand les sites web sources sont connus ils sont cités. Cette page me sert d'aide mémoire, elle peut donc contenir des erreurs, voir même de honteux copier-coller d'autres sites.
===== Matériel =====
* Processeur: Broadcom 5365 @ 200MHz
* Flash: 4Mo
* RAM: 32Mo
* 2 * port USB v.2.0
Source: [[http://http://wiki.openwrt.org/TableOfHardware|OpenWrt Table Of Hardware]]
===== Champs NVRAM =====
==== Général ====
^NVRAM Setting^Meaning^
|wl0_ifname|Set by wlconf to the name of the ethernet interface (eth1, eth2)|
|wl0_hwaddr|Set by wlconf, use il0macaddr to change the mac|
|wl0_mode|Either ap, sta or wet for Access Point mode, station mode or wireless ethernet bridge|
|wl0_ap_isolate|(0/1) 0: allow clients to see each other 1: hide clients from each other|
|wl0_infra|Select operation mode for sta and wet (0=ad-hoc, 1=infrastructure)|
|wl0_closed|(0/1) 0: broadcast ssid 1: hide ssid|
|wl0_country_code|AU = Worldwide, TH = Thailand, IL = Israel, JO = Jordan, CN = China, JP = Japan, US = USA/Canada/New Zealand, DE = Europe, All = All channels|
|wl0_macmode|(disabled/allow/deny) used to (allow/deny) mac addresses listed in wl0_maclist|
|wl0_maclist|List of space separated mac addresses to allow/deny according to wl0_macmode. Addresses should be entered with colons, e.g.: 00:02:2D:08:E2:1D|
|wl0_radio|Enable / disable the radio (1=enable)|
|wl0_channel|The channel to use (default 6, 0=auto channel)|
|wl0_gmode|Set 54g modes (0=Legacy B, 1=auto, 2=G only, 3=B deferred, 4=performance, 5=LRS, 6=afterburner). Note: It may be necessary to use Legacy mode if you want older wireless devices to associate with a WRT access point. If wl0_gmode is not set, the wireless adapter will operate as if it were set to 0.|
|wl0_gmode_protection|For situations where not all wifi stations hear each other|
|wl0_rateset|all|
|wl0_plcphdr|preamble. long: use long or short preamble, *: use short preamble|
|wl0_rate|Set rate in 500 Kbps units (0=auto)|
|wl0_txpwr|Set transmit power in miliwatts|
|wl0_frag|Set fragmentation threshold (default 2346)|
|wl0_rts|Set RTS threshold (256-2347 default 2347)|
|wl0_dtim|Set DTIM period (default 1)|
|wl0_bcn|Set beacon period (default 100)|
|wl0_frameburst|(on/off) enable/disable frameburst|
|wl0_antdiv|Select antenna (-1=auto, 0=main[near power jack], 1=aux[near reset button], 3=diversity) Starting with WRT54G v2.0 and WRT54GS V1.1 these are reversed 0=[near reset button] and 1=[near power jack]|
|wl0_txant|See wl -h|
|wl0_ssid|Set the SSID of the Wrt54g|
|wl0_distance|(per Whiterussian RC5) Adjusts timing for signal propagation time. Unit: [m] (one-way). Setting this variable overrules setting of shortslot/longslot timing. Setting this variable is only needed over distances greater than appr. 1.5 km. The need usually shows when communication throughput is very low although the ratio of signal strength to noise is good.|
|wl0_wdstimeout|if set, it will enable the WDS watchdog (e. g. wl0_wdstimeout=180, value is in seconds)|
==== WEP ====
^NVRAM Setting^Meaning^
|wl0_wep|enabled/disabled|
|wl0_key1 ... wl0_key4|WEP keys (example: wl0_key1=DEADBEEF12)|
|wl0_key|primary key index: the wl0_key[1234] used (values: 1,2,3,4)|
|wl0_auth|1 (shared key) / 0 (open); the 'shared key' option is the most vulnerable WEP option as it most facilitates an intruder due to a fundamental security flaw in WEP. The 'open' setting will allow association but will make it an intruder more difficult to find the encryption key, needed for traffic.|
==== WPA ====
^NVRAM Setting^Meaning^
|wl0_auth_mode|obsolete, use wl0_akm NOTE: set to psk or radius because some configurations don't work without it. See http://www.bingner.com/openwrt/wpa.html, http://wiki.openwrt.org/OpenWrtDocs/Wpa2Enterprise or maybe you can use some other wpa supplicant instead of nas|
|wl0_akm|open,wpa,psk,wpa2,psk2|
|wl0_wpa_psk|WPA pre-shared key|
|wl0_wpa_gtk_rekey|WPA GTK rekey interval|
|wl0_radius_ipaddr| |
|wl0_radius_key| |
|wl0_radius_port|Default value: 1812|
===== Configuration réseau =====
==== Nom et rôle des interfaces ====
^ Nom ^ Rôle ^
| br0 | LAN |
| eth0 | LAN |
| vlan0 | LAN |
| vlan1 | WAN |
| eth1 | WIFI |
==== Configuration de l'interface WAN (br0) ====
nvram set wan_ifname=vlan1
nvram set lan_ifname=br0
nvram set wan_proto=static
nvram set wan_ipaddr=192.168.0.1
nvram set wan_netmask=255.255.255.0
nvram set wan_gateway=192.168.0.254
nvram set wan_dns="208.67.222.222 208.67.220.220"
nvram commit
==== Configuration WPA + AES ====
nvram set wl0_ssid='Prout'
nvram set wl0_channel=3
nvram set wl0_infra=1
nvram set wl0_closed=1
nvram set wl0_akm=psk2
nvram set wl0_crypto=aes
nvram set wl0_mode=ap
nvram set wl0_wpa_psk='XXXXXXXXXXXX'
nvram commit
Sources:
* http://www.macsat.com/macsat/content/view/14/30/
* http://wiki.openwrt.org/OpenWrtDocs/Configuration#head-b62c144b9886b221e0c4b870edb0dd23a7b6acab
* http://wiki.openwrt.org/OpenWrtDocs/nas
===== Configuration logicielle =====
==== Configuration de l'heure au démarrage ====
Créer le fichier ''/etc/init.d/S55ntpclient''
#!/bin/sh
# kill any existing ntpclient processes
# (they can get stuck if no route to target host)
/usr/bin/killall ntpclient
# do time sync
/usr/sbin/ntpclient -l -h 77.234.200.98 -s
chmod +x /etc/init.d/S55ntpclient
===== Stockage sur clef usb =====
ipkg install kmod-usb-core
ipkg install kmod-usb2
ipkg install kmod-usb-storage
ipkg install kmod-usb-uhci
ipkg install kmod-ext2
reboot
Pour monter la clef usb sur /opt à chaque démarrage, éditer le fichier /etc/init.d/S11mount:
#!/bin/sh
# Which device needs to be mounted?
MOUNT_DEVICE0=/dev/scsi/host0/bus0/target0/lun0/part1
i=0
# Wait 15 secs, mount when ready, and continue if it dosnt get ready within 15 secs.
while [ $i -le 15 ]
do
if [ -e $MOUNT_DEVICE0 ]
then
mount $MOUNT_DEVICE0 /opt/
echo "Success: $MOUNT_DEVICE0"
exit 0
fi
sleep 1
i=`expr $i + 1`
done
chmod +x /etc/init.d/S11mount
Source:
* http://www.macsat.com/macsat/
===== Installation des paquets dans /opt avec ipkg =====
Editer /etc/ipkg.conf:
src whiterussian-nbd http://downloads.openwrt.org/people/nbd/whiterussian/packages
src non-free http://downloads.openwrt.org/whiterussian/packages/non-free
dest root /
dest opt /opt
dest ram /tmp
ipkg -d opt install < package-name >
==== Changement du path pour ajouter /opt ====
Editer /etc/profiles pour ajouter:
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
export LD_LIBRARY_PATH=/lib:/usr/lib:/opt/usr/lib:/opt/lib
==== Script pour lancer au démarrage des programmes dans /opt/etc/init.d ====
vi /etc/init.d/S98optfiles
#!/bin/sh
i=0
while [ $i -le 30 ]
do
if [ -d /opt/etc/init.d ]
then
for i in /opt/etc/init.d/S*; do
$i start 2>&1
done | logger -s -p 6 -t '' &
break
fi
sleep 1
i=`expr $i + 1`
done
chmod +x /etc/init.d/S98optfiles
Source:
* http://www.macsat.com/macsat/
===== Installation de screen =====
ipkg -d opt install screen
ln -s /opt/usr/share/terminfo/ /usr/share/terminfo
===== Installation de irssi =====
ipkg -d opt install glib1
ipkg -d opt install irssi
===== Verifier l'ip d'une interface et refaire la configuration si besoin =====
#!/bin/sh
#set -xv
WAN_IFACE=vlan1
LAN_IFACE=br0
WAN_PROTO=static
WAN_IP="192.168.0.1"
WAN_NETMASK="255.255.255.0"
WAN_GATEWAY="192.168.0.254"
WAN_DNS="208.67.222.222 208.67.220.220"
IFCONFIG_REGEXP="inet addr:"
SUCCES=0
ip=$(/sbin/ifconfig $WAN_IFACE | grep "$IFCONFIG_REGEXP" | cut -d ':' -f2 | cut -d ' ' -f1)
if [ $? -ne $SUCCES ]
then
exit 1
fi
if [ $ip = $WAN_IP ]
then
exit 0
fi
nvram set wan_ifname=$WAN_IFACE
nvram set lan_ifname=$LAN_IFACE
nvram set wan_proto=$WAN_PROTO
nvram set wan_ipaddr=$WAN_IP
nvram set wan_netmask=$WAN_NETMASK
nvram set wan_gateway=$WAN_GATEWAY
nvram set wan_dns=$WAN_DNS
nvram commit
reboot
exit 0
===== Utilisation de cron =====
Les scripts à lancer sont sur la clef usb dans /opt/etc/crontabs/
cd /opt/etc/
mkdir crontabs
cd crontabs
mkdir cron.daily
mkdir cron.halfhourly
mkdir cron.hourly
mkdir cron.monthly
mkdir cron.weekly
Création d'un script runparts.sh dans /opt/usr/bin
#!/bin/sh
if [ -z "$1" ]
then
echo "Usage : $0 "
fi
RUNDIR=$1"/*"
for i in $RUNDIR ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
#$i start
;;
esac
done
chmod +x /usr/bin/runparts.sh
Création du script /etc/crontabs/root:
# Syntax for lines is : minute hour day month dayofweek command #
#*/5 * * * * /opt/usr/bin/runparts.sh /opt/etc/crontabs/cron.5mins
*/30 * * * * /opt/usr/bin/runparts.sh /opt/etc/crontabs/cron.halfhourly
* */1 * * * /opt/usr/bin/runparts.sh /opt/etc/crontabs/cron.hourly
02 4 * * * /opt/usr/bin/runparts.sh /opt/etc/crontabs/cron.daily
22 4 * * 0 /opt/usr/bin/runparts.sh /opt/etc/crontabs/cron.weekly
42 4 1 * * /opt/usr/bin/runparts.sh /opt/etc/crontabs/cron.monthly
Source:
* http://www.macsat.com/macsat/
===== Repos ipkg intéressant =====
* [[http://downloads.openwrt.org/backports/0.9/|Openwrt backports]]
* [[http://www.ipkg.be/| IPKG.be - OpenWrt Package Repository Tracker]]