Vous êtes sur la page 1sur 27

2/15/13

Useful Scripts - DD-WRT Wiki

Log in / create account


Go

Main Page Community portal Current events Recent changes Random page Help Donations

Useful Scripts
From DD-WRT Wiki
You are here: DD-WRT wiki mainpage / Scripting / Useful Scripts Certain scripts can enhance the function of your router with DD-WRT, giving it more features or customizing it towards your needs. To find out how to load scripts onto the router, see Startup Scripts.

Contents
1 Modifying $PATH at Startup 2 LED Scripts 3 Miscellaneous Scripts 3.1 Backup settings and restore them 3.2 Clear ttraff (WAN bandwidth graph) nvram data 3.2.1 The other way (NEW, 2012) 3.3 Compress the Firewall Script (to reduce nvram usage) 3.4 Web Server Wake-up 3.5 Auto Random MAC Address 3.6 Wireless Network Scanner (awk -f scanner) 3.7 Wireless Network Scanner (working on DD-WRT v24) 3.8 Name-based WOL (wake.sh) 3.9 Name-based WOL with dnsmasq 3.10 Automatic Connection Repair (always_on.sh) 3.11 Modifying $PATH Manually (path.sh) 3.12 View Logfile in Browser without Local Syslogd (log.sh) 3.12.1 First Method: Script Generated Live-content 3.12.2 Second Method: Static Generated HTML
www.dd-wrt.com/wiki/index.php/Useful_Scripts 1/27

2/15/13

Useful Scripts - DD-WRT Wiki

3.13 Speak Your Signal Strength 3.14 Small Security Script (Firewall) 3.15 Secure remote management for a WAP 3.16 Directory Listing for DD-WRT Micro 3.17 Reset Wireless Radio 3.18 Display Connection Counts Per IP 3.18.1 For local IP's 3.18.2 Foa all IP's 3.19 L2TP Fix for HOT users (obsolete) 3.20 Email Bandwidth Usage Daily 3.21 Update Allowed Remote IP Range by DNS lookup 3.22 Other Useful Misc. Scripts 4 See Also

Modifying $PATH at Startup


This will add whatever paths you want for $PATH and $LD_LIBRARY_PATH before the default system path. Change the paths to whatever you like. Have a good reason for doing this, it should be considered a hack until the feature is implemented permanently.
r - /m/ePoie m f tpnwrfl ha -1/t/rfl |sds==mcbn/htvrbn!> /m/ePoie ed n ecpoie e !!/m/i:waee/i: > tpnwrfl ti -1/t/rfl |sds==mclb/htvrlb!> /m/ePoie al n ecpoie e !!/m/i:waee/i: > tpnwrfl mut-bn /m/ePoie/t/rfl on -id tpnwrfl ecpoie

If you're adding /mmc/lib before the system library, in some circumstances you'll also need to do this on startup (after ensuring that the ldconfig on /mmc is up to date and happy):
mut-bn /m/t/ds.of/t/ds.of on -id mcecl.ocn ecl.ocn mut-bn /m/t/ds.ah /t/ds.ah on -id mcecl.occe ecl.occe

Note: Only do this if you're receiving segmentation faults or your applications are failing to run, and even then only if you feel that this hack is imperative. Also note that if you're attempting this with Optware, the files are ldopt.so.conf and ld-opt.so.cache Another alternative to the above mentioned way of altering things is to simply copy /etc/profile to /jffs/etc, change PATH and LD_LIBRARY_PATH and bind the profile to the original location.
mdr/fsec ki jf/t c /t/rfl /fsecpoie p ecpoie jf/t/rfl c /fsec d jf/t v poie(hneeeyhnsta sieyu nesadsv i wt :) i rfl cag vrtig ht ut or ed n ae t ih x

Afterward put the line below inside a startup script


www.dd-wrt.com/wiki/index.php/Useful_Scripts 2/27

2/15/13

Useful Scripts - DD-WRT Wiki

mut-bn /fsecpoie/t/rfl on -id jf/t/rfl ecpoie

Make sure you're familiar with what you're doing before attempting this, if you end up seeing a lot of segmentation faults when running things like ls, cat, cp, etc, than you'll want to either adjust the above commands, or else put those things into a script and run them manually when you enter your shell.

LED Scripts
See LED Scripts

Miscellaneous Scripts
Backup settings and restore them
Credit to hardwarewizard and frater Reference Thread (http://www.dd-wrt.com/phpBB2/viewtopic.php?t=44324)
#/i/h !bns ############################# ############################ # Srp Rqieet cit eurmns # # Fls ie: # vr_osi ast_kp # vr_rfre aspeerd # # Porm: rgas # cr ul ############################# ############################ ############################# ############################ #stpvrals eu aibe # #DT AE -Dt ae #MC A -Mcades a drs #FL IE -Fl Nm Pei ie ae rfx #CRDR U_I -CretDrcoy urn ietr #tase rnfr -FPTase O/F (eal i OF T rnfr NOF Dfut s F) #FLE ODR -Lcto weebcu srpsaesoe oain hr akp cit r trd #VRIE AFL -Lcto &Nm o Tm Fl oain ae f ep ie #T_L OAL -Lcto &Nm o srp Fl wt alnrmvrals oain ae f cit ie ih l va aibe #T_NLD OICUE -Lcto &Nm o srp Fl wt esnilnrmvrals oain ae f cit ie ih seta va aibe #T_XLD OECUE -Lcto &Nm o srp Fl wt dneosnrmvrals oain ae f cit ie ih agru va aibe #T_RFRE OPEERD -Lcto &Nm o srp Fl wt peerdnrmvrals oain ae f cit ie ih rfre va aibe # ############################# ############################ DT=dt +mdY AE`ae %%%` MC`va gtlnhad |t - "" A=nrm e a_wdr r d :` FL={A}$DT} IE$MC.{AE CRDR`inm $` U_I=drae 0 tase= rnfr0 FLE=otvr/akp ODR/p/asbcus
www.dd-wrt.com/wiki/index.php/Useful_Scripts 3/27

2/15/13

Useful Scripts - DD-WRT Wiki

VRIE/p/m/l_as AFL=ottpalvr T_L={ODR/{A}$DT}als OAL$FLE}$MC.{AE.l.h T_NLD={ODR/{A}$DT}esnils OICUE$FLE}$MC.{AE.seta.h T_XLD={ODR/{A}$DT}dneoss OECUE$FLE}$MC.{AE.agru.h T_RFRE={ODR/{A}$DT}peerds OPEERD$FLE}$MC.{AE.rfre.h ############################# ############################ #T Lgnifraincag t yu if FP oi nomto hne o or no ############################# ############################ FP=t:/9.6..0/akp TSfp/1218110bcus UEPS=srps SRASue:as ############################# ############################ #ra cmadln sice ed omn ie wths # # eapecmadlns xml omn ie # # .bcuvr.h/akpass t # # Teaoecmadwt ueteue adpswr ad h bv omn ih s h sr n asod n # sre ifrainebde i ti srp. evr nomto medd n hs cit # (e FPLgnifrainaoe Se T oi nomto bv) # # # .bcuvr.h- - ue:as- fp/1218110bcus /akpass t u srps f t:/9.6..0/akp # # Teaoecmadwt ueteue adpswr ad h bv omn ih s h sr n asod n # sre ifrainfo tecmadln evr nomto rm h omn ie # ############################# ############################ wiegtpst::nm hl eot uf ae d o cs $aei ae nm n t ) tase=; rnfr1; u ) UEPS=$PAG; SRAS"OTR"; f ) FP=$PAG; TS"OTR"; ? ) pit "sg:%:[t [uuenm:asod [ffpevr\" rnf Uae s -] sraepswr] tsre]n ei 2; xt ; ea sc dn oe sit$(OTN -1) hf ($PID ) ############################# ############################ #raeNRMvraels adwiet /p/m/l_as cet VA ail it n rt o ottpalvr ############################# ############################

nrmso 2/e/ul|erp'[-az[-az-_.-*'|ak- ='pit$} |sr - - >{A va hw >dvnl ge ^AZ-]AZ-09\\]= w F {rn 1' ot r u $VR ############################# ############################ #Wiehae t rsoesrps rt edr o etr cit ############################# ############################

eh - "!bns\#nco\Wievrals"n |te- $T_XLD}|te- $T_RFRE}|te co e #/i/hn\eh "rt aibe\\" e i {OECUE e i {OPEERD e ############################# ############################ #sa NRMvral ls adsn vral t poe cn VA aibe it n ed aibe o rpr #rsoesrp etr cit ############################# ############################ ct$VRIE |wiera vr a {AFL} hl ed a d o pe= rf0 ##rpae wt nx ln b AdnMne : i eh "{a} |ge - - "{U_I}vr_osi" # elcd ih et ie y no av f co $vr" rp q f $CRDR/ast_kp
www.dd-wrt.com/wiki/index.php/Useful_Scripts 4/27

2/15/13

Useful Scripts - DD-WRT Wiki

i ct"{U_I}vr_osi"|ge - "{a} f a $CRDR/ast_kp rp q $vr" ;te hn bie$OECUE fl=T_XLD es le bie$OICUE fl=T_NLD pe=eh "{a} |ge -f"{U_I}vr_rfre" rf`co $vr" rp c $CRDR/aspeerd` f i #gttedt oto tevral e h aa u f h aibe dt=nrmgt$vr` aa`va e {a} #wietevrt tefl adue\frseilcas ($" rt h a o h ie n s o pca hr: \`) eh -n"va st$vr=" |te-a$T_L}> $bie co e nrm e {a}\" e i {OAL > {fl} eh - "{aa"| sd- '/$"]\&g |te-a $T_L}> $bie co n $dt} e e s[`\/\/' e i {OAL > {fl} eh - "" |te-a $T_L}> $bie co e \" e i {OAL > {fl} i [!$pe}= 0] te f {rf = ; hn eh -n"va st$vr=" > $T_RFRE} co e nrm e {a}\" > {OPEERD eh - "{aa"| sd- '/$"]\&g > $T_RFRE} co n $dt} e e s[`\/\/' > {OPEERD eh - "" > $T_RFRE} co e \" > {OPEERD f i dn oe ############################# ############################ #cenprmv /p/m/l_as lau eoe ottpalvr #ucmett rmv fl nomn o eoe ie ############################# ############################ #r $VRIE m {AFL} ############################# ############################ #Wiefoe t rsoesrp rt otr o etr cit ############################# ############################

eh - "n Cmi vralsnco\Sv vralst nrm"nva cmi" |te-a $T_L}|t co e \# omt aibe\eh "ae aibe o va\\nrm omt e i {OAL ############################# ############################ #Cag prisoso rsoesrpst mk te hne emsin n etr cit o ae hm #eeual xctbe ############################# ############################ cmd+ $T_NLD} ho x {OICUE cmd+ $T_RFRE} ho x {OPEERD cmd+ $T_XLD} ho x {OECUE cmd+ $T_L} ho x {OAL ############################# ############################ #Cmrs rsoesrpsadsn te t fpsre opes etr cit n ed hm o t evr ############################# ############################

i [$tase}-e0];te f {rnfr n hn trcf-- /"{OICUE"2/e/ul|gi - | /p/i/ul- - $UEPS}"{TS/{I a p C $T_NLD} >dvnl zp c otbncr s u {SRAS $FP}$FL trcf-- /"{OPEERD"2/e/ul|gi - | /p/i/ul- - $UEPS}"{TS/{ a p C $T_RFRE} >dvnl zp c otbncr s u {SRAS $FP}$F trcf-- /"{OECUE"2/e/ul|gi - | /p/i/ul- - $UEPS}"{TS/{I a p C $T_XLD} >dvnl zp c otbncr s u {SRAS $FP}$FL trcf-- /"{OAL"2/e/ul|gi - | /p/i/ul- - $UEPS}"{TS/{IE. a p C $T_L} >dvnl zp c otbncr s u {SRAS $FP}$FL}a f i

The vars_to_skip file


D_OR DBAD ^or bad bosrmto rwe_ehd ^f ce c_oue tmdls
www.dd-wrt.com/wiki/index.php/Useful_Scripts 5/27

2/15/13

Useful Scripts - DD-WRT Wiki

cso_htoncmad utmsudw_omn ^e_ df ^eal_ dfut ds_ye ittp d_a_dr lrmad erysatpcmad al_tru_omn ^t e0 ^t e1 ^z ec gnrt_e eeaeky gzl_cin oiaato gi po ^adae hrwr ^s i_ ^enl kre_ lndfut a_eal ^a_w lnh ^a_fae lninm lnes adv mna_otn aulbo_v ms_omd ici_oe ne_omt edcmi ^s o_ oecokn vrlcig p0apr amxw pydnm hi_u po_e mnvr pp_pinm pdppfae ppeinm po_fae ppewninm po_a_fae piayinm rmr_fae poebakit rb_lcls rglto_oan euaindmi rsu ece rst ee_ srth cac srm da ^h s_ ^kp si sh_s_otky sddshs_e sh_s_otky sdrahs_e satpcmad tru_omn ^a_eal wndfut ^a_w wnh ^a_f wni ^a_pr wnvot ^adv wnes wbho_irre e_oklbais ^ii wf_ w01had l._wdr w02had l._wdr w03had l._wdr w0had l_wdr w0inm l_fae w0rdod l_aiis ^l w_ ^ln wa_

The vars_preferred file. This is the file you add your vars to that you want to backup.
dyih_ie algttm tm_oe iezn
www.dd-wrt.com/wiki/index.php/Useful_Scripts 6/27

2/15/13

Useful Scripts - DD-WRT Wiki

this is an updated version

Clear ttraff (WAN bandwidth graph) nvram data


The ttraff daemon can fill up a couple hundred bytes of nvram space every month. This may not seem like much but nvram is only ~32KB total and is full of lots of other data. Disabling ttraff and clearing it's old nvram data is sometimes needed for devices with complex configurations, or to keep the router stable. This script will clear all of ttraff's traffic data from nvram whereas using the ttraff GUI button to delete it still leaves the current month's variable.
frii `va so |ge taf |ct-1-=";d nrmust$;dn o n nrm hw rp rfu f d"` o va ne i oe

The other way (NEW, 2012)


If you want to keep always one year of history, use the one below in your startup script to prune old data (no cron needed, and it doesn't require a correct date is set e.g. with ntpd: the script unsets nvram entries elder than 12 monthes before the most recent data available, i.e. 13 data sets, current month plus last 12). As the aim is to reclaim nvram storage and as the startup script is stored in nvram, I tried to keep it the slimmest possible (no indentation, no function whose declaration would have store more space than duplicated commands, single command per line to spare one out of the two "; " bytes separator (single line return instead), no [tmp]file stored and single letter variables T for Traff or Threshold, D for Dates and N for nvram. Any other shrink trick is welcome. Should you run your dd-wrt unattended for years with traffmon enabled, you should use this script or you'll run one day or the other into a nvram outage and its fancy effets as wireless changing ciphering mode etc... You can adjust how long the log you'll keep will be by changing the integer "100" in the eleventh line: the first loop searches the max (say current) data set date, in YYYYMM format, then the T=`expr ...` line sets the lower (threshold) that will be kept, e.g 200 for 2 years, 109 for 1 year plus 9 monthes. A last word, about the current data set date "detection". Initial T and subsequent loop could have been replaced by a simple T=`date +%Y%m` or more condensed the script could have begun with T=`expr `date +%Y%m` - 100` (26 chars against 31 -don't forget threshold setting-, but not checked), but as year start on 1970 on startup until a true ntp date is available, the script would not work reliabily - although this could be used with the script as custom script ran from cron, say monthly, with the help of a replacement check that year date is not 1970 (or better: higher than eldest data set, to protect against any firmware change, but here the script size increases).
#/i/h !bns T0 = D`va so|rptaf|u -1-=ak-""'pit$,2'ct--,=nrm hwge rf-ct f d|w F{rn 3$}|u b46` frdi $ o n D d o i [$ -t$ ] f T l d te hn T$ =d f i dn oe T`xr$ -10 =ep T 0` frdi $ o n D d o i [$ -t$ ] f T g d te hn
www.dd-wrt.com/wiki/index.php/Useful_Scripts 7/27

2/15/13

Useful Scripts - DD-WRT Wiki

Ntaf`co$d|u -5``co$d|u --` =rf-eh {}ct b--eh {}ct b4 nrmust$ va ne N f i dn oe

Thank you JLL and Glenfarclass and Cardhu for the help --Bib 02:13, 12 November 2012 (CET)

Compress the Firewall Script (to reduce nvram usage)


If you have a large firewall script you can use this script to compress it with gzip to use less nvram space. See this thread (http://www.dd-wrt.com/phpBB2/viewtopic.php?p=432543) for full usage info.
#Cmrs Frwl opes ieal nrmstp_w"nrmgtr_ieal|gi |uecd - /e/tot" va e Hf=`va e cfrwl zp unoe m dvsdu` nrmstr_ieal"va gtp_w|udcd - /m/Hf.zgni /m/Hf.zcmd+ va e cfrwl=nrm e Hf ueoe o tpp_wg;uzp tpp_wg;ho x /m/Hf;tpp_w tpp_w/m/Hf" nrmso >dvnl va hw /e/ul

#Dcmrs Frwl eopes ieal nrmgtp_w|udcd - /m/Hf.z va e Hf ueoe o tpp_wg nrmustp_w va ne Hf gni /m/Hf.z uzp tpp_wg nrmstr_ieal"ct/m/Hf` va e cfrwl=`a tpp_w" nrmso >dvnl va hw /e/ul

#EiigteFrwl dtn h ieal v /m/Hf i tpp_w #fns eiigwt v bfr rnigters iih dtn ih i eoe unn h et nrmstr_ieal"ct/m/Hf` va e cfrwl=`a tpp_w" nrmso >dvnl va hw /e/ul

Web Server Wake-up


Wakes up your web server when the router receives a request from the internet. Credits from here. (http://gaddgets.blogspot.com/2007/02/auto-wol-on-dd-wrt-on-linksys-wrt54gl.html) RET value from that script did not work here, using if ping else statement below. --rasos 29NOV2010 Please note: syslogd needs to be on, logging enabled, with log level set high, and "accepted" on. Following the example script, replace target and MAC values with those of your LAN web server's network information and for "$WOL -i xxx.xxx.xxx.255", replace xxx.xxx.xxx.255 with your LAN network broadcast address.
#/i/h !bns ITRA= NEVL5 NM= UP3 OD" L=" WL/s/bnwl O=ursi/o TRE=9.6..8 AGT121831 MC0:61:FE:1 A=02:8C:1E LGIE"tpwwwllg OFL=/m/w/o.o"

www.dd-wrt.com/wiki/index.php/Useful_Scripts

8/27

2/15/13

Useful Scripts - DD-WRT Wiki

wiesep$NEVLd hl le ITRA;o NW`w 'ACP/& /S="TRE"/& /P=0 {rn } /a/o/esgs|ti -` E=ak /CET & DT'$AGT' & DT8/ pit ' vrlgmsae al 1 SC`w -'= ] 'ACP/& /S="TRE"/& /P=0 {rn } /a/o/esgs|ti -` R=ak F[| ' /CET & DT'$AGT' & DT8/ pit ' vrlgmsae al 1 LN=ak'ACP/& /S="TRE"/& /P=0'/a/o/esgs IE`w /CET & DT'$AGT' & DT8/ vrlgmsae` i ["NW ! " - "NW ! "OD ] te f $E" = " a $E" = $L" ; hn i pn -c$UP$AGT>dvnl;te f ig q NM TRE /e/ul hn eh "TRE wsacse b $R adi aiea"`ae co $AGT a cesd y SC n s lv t dt` > $OFL > LGIE es le eh "SCcue wk o lna"`ae co $R ass ae n a t dt` > $OFL > LGIE $O - 1218325- 7$A WL i 9.6..5 p MC > $OFL > LGIE sep5 le f i OD$E L=NW f i dn oe

Unfortunately that script wasn't working with V24-SP2's logging. I rewrote it to use dmesg and added some logging messages to help. Thanks go to rasos for the initial script!
#/i/h !bns #nbeJF2adpaesrp i /fs te rno satpi wbitrae Eal FS n lc cit n jf/ hn u n tru n e nefc. #o cncektelgfo ht:/9.6../srwlhm Yu a hc h o rm tp/121811ue/o.tl ITRA= NEVL5 NM= UP3 OD" L=" PR=0 OT8 WLOT9 OPR= TRE=9.6..0 AGT1218111 BODAT1218125 RACS=9.6..5 MC0:12:34:5 A=01:23:45 WL/s/bnwl O=ursi/o LGIE"tpwwwlhm" OFL=/m/w/o.tl eh "mt ht-qi="ers\ cnet\1\> >$OFL co <ea tpeuv\rfeh" otn="0"" LGIE eh "UOWLSrp satda"`ae "b> > $OFL co AT O cit tre t dt` <r" > LGIE wiesep$NEVLd hl le ITRA;o NW`ms |ak'ACP/& /S="TRE"/& /P="PR"/{rn } |ti -` E=deg w /CET & DT'$AGT' & DT'$OT' pit ' al 1 SC`ms |ak-'= ] 'ACP/& /S="TRE"/& /P="PR"/{rn $} |ti -` R=deg w F[| ' /CET & DT'$AGT' & DT'$OT' pit 7' al 1 LN=deg|ak'ACP/& /S="TRE"/& /P="PR"/` IE`ms w /CET & DT'$AGT' & DT'$OT'' i ["NW ! " - "NW ! "OD ] te f $E" = " a $E" = $L" ; hn i pn -c$UP$AGT>dvnl;te f ig q NM TRE /e/ul hn eh "OAE$AGTwsacse b $R adi arayaiea"`ae "b>> $OFL co NWK TRE a cesd y SC n s led lv t dt` <r"> LGIE es le eh "AE$R cue wk o lna"`ae "b>> $OFL co WK SC ass ae n a t dt` <r"> LGIE $O - $RACS - $OPR $A > $OFL WL i BODAT p WLOT MC > LGIE eh "b> > $OFL co <r" > LGIE sep5 le f i OD$E L=NW f i dn oe

Auto Random MAC Address


www.dd-wrt.com/wiki/index.php/Useful_Scripts 9/27

2/15/13

Useful Scripts - DD-WRT Wiki

This script will change your eth1 MAC address to a random address, then it will apply it to the system and restart the interfaces.

#/i/s !bnah MC`dt;ct/rcitrut)|m5u |sd- '/({0)*/1;s(09-]2)\:g s:/;` A=(ae a po/nerps dsm e r s^.1}.$\/ /[-af{}/1/; /$/' eh "0$MC" co 0:{A} icni eh h ehr0:{A} fofg t1 w te 0$MC nrmstdfhad=0:{A} va e e_wdr"0$MC" nrmstwnhad=0:{A} va e a_wdr"0$MC" sosriewn tpevc a satevc wn trsrie a

You may wish to also download curl (see ipkg), and use it to restart your modem, as some MAC changes may not reflect until your modem "sees" a new address, and they typically only do this when starting up. Note: curl is sometimes problematic to install. You should use ipkg -force-depends An example, to restart a Motorola Surfboard SB4100 cable model is:
cr - - "UTNIPTRsatCbeMdm ht:/9.6.0./ofgaahm ul s d BTO_NU=etr+al+oe" tp/1218101cnidt.tl

To restart a Motorola SB5101:


cr - Rste= ht:/9.6.0./oomRCni ul d eeRq1 tp/1218101gfr/gofg

I added the following lines to the end of the above to restart a Motorola SB5120 (no curl required!!) and reboot. Running this script in cron, and my ISP won't automatically recover without the following:
nrmcmi &sep5& we ht:/9.6.0./ee.t?ee_oe=etr+al+oe va omt le & gt tp/1218101rsthmrstmdmRsatCbeMdm rbo eot

Don't know the reason but Motorola SB5101 only re-started with the two following lines:
cr - - "etrFcoyeal=&eeRq1 ht:/9.6.0./oomRCni ul v d RsoeatrDfut1Rste=" tp/1218101gfr/gofg cr - Rste= ht:/9.6.0./oomRCni ul d eeRq1 tp/1218101gfr/gofg

Wireless Network Scanner (awk -f scanner)


########### ########## ct->sanr a cne #So sarslsi cnitn odrwt gahclbr. hw cneut n osset re ih rpia as #T b rnvatle t WT4 rnigmdfe frwr. o e u i ent o R5g unn oiid imae #D tefloig Ueyu onrue adesisedo 121811o tefloiglns o h olwn. s or w otr drs nta f 9.6.. n h olwn ie #Lgnvatle: oi i ent # tle 121811 ent 9.6.. #asml ts t mk sr yucnrnti srp,tp: ipe et o ae ue o a u hs cit ye
www.dd-wrt.com/wiki/index.php/Useful_Scripts 10/27

2/15/13

Useful Scripts - DD-WRT Wiki

# w sa;w sarsls l cn l cneut #admk sr yucnrntoecmad.I ntti pormwl ntwr. n ae ue o a u hs omns f o hs rga il o ok #I yusceddwt tesarslste f o ucee ih h cneut hn #cp adpseti etr tx it tetria wno oy n at hs nie et no h emnl idw #(h ct->sanrln wl cp ters o tefl it afl nmd'cne' te a cne ie il oy h et f h ie no ie ae sanr) #adte htrtr adte cr- t coetefl. n hn i eun n hn tlc o ls h ie #te js rnsrp b tpn tefloigln: hn ut u cit y yig h olwn ie # ak- sanr w f cne # #Ihrb rlaeti it tepbi dmi.Jsi Jns 20 eey ees hs no h ulc oan utn oe, 05 # #Jn '7cretdbgfo '6ipoeet a. 0 orce u rm 0 mrvmn.

BGN EI{ INRCS =1 GOEAE ; cmad="lsa 2 /e/ul;w sarsls2 /e/ul; omn w cn > dvnl l cneut > dvnl" rd="xb3m; e \1[1" gen="xb3m; re \1[2" genak"xb4m; rebc=\1[2" ylo ="xb3m; elw \1[3" ca ="xb3m; yn \1[6" bu ="xb3m; le \1[4" bubc ="xb4m; leak \1[4" wie="xb3m; ht \1[7" wieak="xb4m; htbc \1[7" rst="xb0" ee \1[m; udrcr ="xb4" nesoe \1[m; cer="xb2" la \1[J; hm ="xb00" oe \1[;H; eaeed="xbK; rs2n \1[" cae=wie Nm ht; cinl=gen Sga re; cos =rd Nie e; cas=gen Cp re; ctegho =bu bubc; chne =gen SrntLw le leak Canl re; cteghe =wiewieak SrntMd ht htbc; cteghi=gengenak SrntH re rebc; cteghgd=rd SrntAe e; pitcer rn la; fr;) o(; { wie(omn|eln) hl cmadgtie { i(^SD){nm =; rs =;os=;rs=" nie";hne="bsd";as"} f/SI/ ae si nie si"; os="canl";si="cp=" i(^oe){si=;os=;canl= } f/Md/ rs nie hne i(^SI/ {si =;cp ="" " " " " "} f/BSD) bsd as " " " " " i(^upre/ f/Spotd) { nm[si]=nm aebsd ae rs[si]=rs sibsd si niebsd=nie os[si] os canlbsd =canl hne[si] hne cp[si]=cp asbsd as } } coecmad ls(omn) pit hm; rnf oe l =0 n ; pitwie"Nm rn ht ae BSD Sga NieCanlTp" SI inl os hne ye; fr( i nm) o x n ae { { #rirr srnt cl truhtiladerr. mdf a yuws: abtay tegh ac hog ra n ro.. oiy s o ih sgtegh=(rs[]-niex)15 +(rs[]+0*.) isrnt (six os[]*.) (six 9)15; i (isrnt <)sgtegh0 f sgtegh 1 isrnt=; ctegh=ctegho; Srnt SrntLw i(isrnt>)ctegh=cteghe; fsgtegh4 Srnt SrntMd i(isrnt>)ctegh=cteghi fsgtegh7 Srnt SrntH; i(g[]0 ctegh=cteghgd faex=) Srnt SrntAe; ft="s-5 %%"isrnt" "ee eaeed"n m %%1s s0sgteghd rst rs2n \
www.dd-wrt.com/wiki/index.php/Useful_Scripts

% s %%4 %%4 %%4 %%s%%0 s-d s-d s-d s2 s1s


11/27

2/15/13

Useful Scripts - DD-WRT Wiki

pit ft caenm[]ctegh0xcinlrs[]cos,os[]chne,canlx,C rnf m, Nm,aex,Srnt,,,Sga,six,Nieniex,Canl hne[]ca rs[]="10 xx" six -00 xx; l+; n+ }

} i (n=0 pitrd"oRsls-D yuhv w sa cpblt?\Ti pormdpnso 'lsa f l =) rn e N eut o o ae l cn aaiiy nhs rga eed n w cn piteaeed rn rs2n; } }

Wireless Network Scanner (working on DD-WRT v24)


I took the above script and tweaked it to work in DD-WRT v24 firmware, with the "wl" command. To run just copy and paste in a console (telnet or ssh) or save as a "scanner.sh" and run as ./scanner.
#/i/h !bns ak-"]] ' w F[[" BGN EI{ INRCS =1 GOEAE ; cmad="iesre 2&" omn st_uvy >1; rd="xb3m; e \1[1" gen="xb3m; re \1[2" genak"xb4m; rebc=\1[2" ylo ="xb3m; elw \1[3" ca ="xb3m; yn \1[6" bu ="xb3m; le \1[4" bubc ="xb4m; leak \1[4" wie="xb3m; ht \1[7" wieak="xb4m; htbc \1[7" rst="xb0" ee \1[m; udrcr ="xb4" nesoe \1[m; cer="xb2" la \1[J; hm ="xb00" oe \1[;H; eaeed="xbK; rs2n \1[" cae=wie Nm ht; cinl=gen Sga re; cos =rd Nie e; cas=gen Cp re; ctegho =bu bubc; chne =gen SrntLw le leak Canl re; cteghe =wiewieak SrntMd ht htbc; cteghi=gengenak SrntH re rebc; cteghgd=rd SrntAe e; pitcer rn la; fr;) o(; { wie(omn|eln) hl cmadgtie { i (= ")cniu; f = " otne bsd; si= nm[si]=; aebsd rs[si]=; sibsd niebsd=; os[si] canlbsd =; hne[si] cp[si]=; asbsd aebsd =1 g[si] ; } coecmad; ls(omn) pit hm; rnf oe l =0 n ; pitwie"Nm rn ht ae BSD Sga NieCanlTp" SI inl os hne ye; fr( i nm) o x n ae { #rirr srnt cl truhtiladerr. mdf a yuws: abtay tegh ac hog ra n ro.. oiy s o ih
www.dd-wrt.com/wiki/index.php/Useful_Scripts 12/27

2/15/13

Useful Scripts - DD-WRT Wiki

sgtegh=(rs[]-niex)15 +(rs[]+0*.) isrnt (six os[]*.) (six 9)15; i (isrnt <)sgtegh0 f sgtegh 1 isrnt=; ctegh=ctegho; Srnt SrntLw i(isrnt>)ctegh=cteghe; fsgtegh4 Srnt SrntMd i(isrnt>)ctegh=cteghi fsgtegh7 Srnt SrntH; i(g[]0 ctegh=cteghgd faex=) Srnt SrntAe; ft="s-5 %%"isrnt" "ee eaeed"n m %%1s s0sgteghd rst rs2n \ % s %%4 %%4 %%4 %%s" rs s-d s-d s-d s2 ee pit ft caenm[]ctegh0xcinlrs[]cos,os[]chne,canlx,C rnf m, Nm,aex,Srnt,,,Sga,six,Nieniex,Canl hne[]ca rs[]="10xx" six -0 xx; l+; n+

} i (n=0 f l =) pitrd"orsls-D yuhv sre cpblt?\Ti pormdpnso st_uvyt rn rn e N eut o o ae uvy aaiiy nhs rga eed n iesre o u. piteaeed rn rs2n; } } '

Name-based WOL (wake.sh)


Enables you to power on a LAN computer by name instead of IP address/MAC, based on DHCP lease table (mandatory). Usage: / a h t / a e s < o t a e (default hostname is desktop) pt/owk.h hsnm>
SAINm TTO=m WL/s/bnwl O=ursi/o SAIS/m/dcdsais TTC=tpuhp.ttc DVb0 E=r i [f n " ] te " ; hn SAIN TTO= f i wiera LN hl ed IE d o I=eh $IE|ak'pit}` P`co LN w {rn ' MC`co$IE|ak'pit}` A=eh LN w {rn ' FUD`pnih|ge "I.RAHBE` ON=i eg rp $P*ECAL" i [- "FUD ] te f z $ON" ; hn eh Cetn APetyfr$P$A co raig R nr o I MC i nihad$Plad $A dv$E ndrahbe2 /e/ul p eg d I ldr MC e DV u ecal > dvnl i nihcag $Plad $A dv$E ndrahbe2 /e/ul p eg hne I ldr MC e DV u ecal > dvnl f i dn <$TTC oe SAIS

LAE`rp"bSAINb"$TTC` ES=ge \$TTO\$ SAIS i [- "LAE ] te f n $ES" ; hn I=eh $ES |ak'pit}` P`co LAE w {rn ' MC`co$ES |ak'pit}` A=eh LAE w {rn ' $O - $P$A WL i I MC es le eh Ual t fn \$TTO\ i DC sai fl $TTC,pes ue\ \hsnm\\ co nbe o id "SAIN" n HP ttc ie SAIS lae s " <otae>" f i

www.dd-wrt.com/wiki/index.php/Useful_Scripts

13/27

2/15/13

Useful Scripts - DD-WRT Wiki

Name-based WOL with dnsmasq


I updated the above script to work with dnsmasq dhcp reservation.
#/i/h !bns SAIN$ TTO=1 WL/s/bnwl O=ursi/o SAIS/m/nms.of TTC=tpdsaqcn DVb0 E=r i [f z "SAIN ] te $TTO" ; hn eh "o ms seiytehs t wk.Uae $ <otae" co Yu ut pcf h ot o ae sg: 0 hsnm> ei 1 xt f i ge 'hphs'$TTC |wiera LN rp dc-ot SAIS hl ed IE d o I=eh $IE|ak-,'pit$}` P`co LN w F {rn 3' MC`co$IE|ak-[= 'pit$}` A=eh LN w F,] {rn 2' FUD`pnih|ge "I.RAHBE` ON=i eg rp $P*ECAL" i [- "FUD ] te f z $ON" ; hn eh Cetn APetyfri $PadMC$A co raig R nr o p I n A MC i nihad$Plad $A dv$E ndrahbe2 /e/ul p eg d I ldr MC e DV u ecal > dvnl i nihcag $Plad $A dv$E ndrahbe2 /e/ul p eg hne I ldr MC e DV u ecal > dvnl f i dn oe

LAE`rp"$TTO, $TTC` ES=ge ,SAIN" SAIS i [- "LAE ] te f n $ES" ; hn NT`co$ES |ak-,'slt$,p"";rnf"s%.s25,p1,p2,p3)' E=eh LAE w F {pi(3i,.)pit(%.s%.5"i[]i[]i[]}` I=eh $ES |ak-,'pit$}` P`co LAE w F {rn 3' MC`co$ES |ak-[= 'pit$}` A=eh LAE w F,] {rn 2' eh Wkn u $TTO o bodat$E a i $PadMC$A co aig p SAIN n racs NT t p I n A MC $O - $E $A WL i NT MC es le eh "nbet fn \$TTO\ i DC sai fl $TTC. co Ual o id "SAIN" n HP ttc ie SAIS" ei 1 xt f i

Automatic Connection Repair (always_on.sh)


Pings your default gateway every time and force a DHCP renew if no packets are received. Usage: /path/to/always_on.sh &
#/i/h !bns ITRA=0 NEVL1 PCES1 AKT= UHP=uhp - va1- /a/u/dccpd- /m/dcc DCC"dcc i ln p vrrnuhp.i s tpuhp" IAEva1 FC=ln

M=bsnm $` E`aeae 0 RNIG`s|ak''$E' {+} ED{rn x0' UNN=p w /"M"/ +x; N pit +}` i ["RNIG -t3] te f $UNN" g ; hn
www.dd-wrt.com/wiki/index.php/Useful_Scripts 14/27

2/15/13

Useful Scripts - DD-WRT Wiki

eh "nte isac o \$E"i rnig co Aohr ntne f "M\ s unn" ei 1 xt f i wiesep$NEVL hl le ITRA d o TRE=i rue|ak'dfutva {rn $}` AGT`p ot w /eal i/ pit 3' RT`ig- $AKT $AGT2 /e/ul|ak'pcesrcie/{rn $}` E=pn c PCES TRE > dvnl w /akt eevd pit 4' i ["RT -e"PCES ] te f $E" n $AKT" ; hn eh "igfie,rlaigI adeso $FC" co Pn ald eesn P drs n IAE #edaRLAEsga sn EES inl kl -S2`a /a/u/dccpd 2 /e/ul il UR ct vrrnuhp.i` > dvnl #nueuhp i ntrnig esr dcc s o unn klaluhp 2 /e/ul ill dcc > dvnl eh "eeigI ades $FC" co Rnwn P drs: IAE $DCC UHP eh "atn 1 s." co Wiig 0 .. sep1 le 0 es le eh "ewr i u va$AGT co Ntok s p i TRE" f i dn oe

The following version will work even on resource-starved Linksys WRT54G v8, which lacks most programs needed by the script above. To use it, just add this code to DD-WRT's startup script using the web interface.
ITRA=0 NEVL1 wietu;d hl re o wie[\ $w] d hl ! g ; o sep3 le 0 rue- >tprue ot n /m/ots wiera ds g fo d hl ed et w o; o i [$et="..."] te f ds 0000 ; hn bek ra f i dn <tprue oe /m/ots dn oe lge "uorpi:dfutgtwyi $w ogr at-ear eal aea s g" wiepn -c2$w>dvnl ;d hl ig q g /e/ul o sep$NEVL le ITRA dn oe lge "uorpi:gtwydw,rsatn WN ogr at-ear aea on etrig A" kl -S1`a /a/u/dccpd il UR ct vrrnuhp.i` ustg ne w dn & oe

Modifying $PATH Manually (path.sh)


Enables adjustment of paths on a per-use basis (i.e. when you're running a terminal and need the new paths, run this script.).
#/i/h !bns epr PT=PT:mcbn/htvrbn xot AH$AH/m/i:waee/i epr L_IRR_AH$DLBAYPT:mclb/htvrlb xot DLBAYPT=L_IRR_AH/m/i:waee/i

www.dd-wrt.com/wiki/index.php/Useful_Scripts

15/27

2/15/13

Useful Scripts - DD-WRT Wiki

Alternatively, if you want to give priority to you're personally installed applications (i.e. you've installed a more robust version of grep, and want to use it by default), add the new paths before $PATH and $LD_LIBRARY_PATH, as shown below.
#/i/h !bns epr PT=mcbn/htvrbn$AH xot AH/m/i:waee/i:PT epr L_IRR_AH/m/i:waee/i:L_IRR_AH xot DLBAYPT=mclb/htvrlb$DLBAYPT

View Logfile in Browser without Local Syslogd (log.sh)


View the last 1000 lines from your router's logfile in your browser without a locally running syslogd (i.e. Kiwi)

First Method: Script Generated Live-content


Initial post in German forum: SOLVED: messages (logdatei) formatiert ber browser aufrufen (http://www.ddwrt.com/phpBB2/viewtopic.php?p=55922) )
#/i/h !bns eh 'HM>HA>TTELgie/IL>/ED' co <TL<ED<IL>ofl<TTE<HA> eh 'BD><r/nrmgtrue_ae co <OY'b >va e otrnm eh 'Lgie<r<r> co ofl:b>pe' /s/i/al- 10 /a/o/esgs urbnti n 00 vrlgmsae eh '/OY<HM> co <BD>/TL'

To use this script you first need to enable syslog on your router without stating an IP. Then the log will be saved in /var/log/messages. You can do this under Administration->Services and then scroll down to the "System Log" section. Click "Enable" and leave "Remote Server" empty. After you saved the script under /tmp/www/ as "log.sh" you must mark it as executable with "chmod +x /tmp/www/log.sh". You can do that by saving the following in your startup script:

eh -n"!bns\eh 'HM>HA>TTELgie/IL>/ED'nco'BD>\nrmgtrue_ co e #/i/hnco <TL<ED<IL>ofl<TTE<HA>\eh <OY'nva e otrn

To view the log in your browser point it to "http://<routerip>/user/log.sh" It appears that the above method doesn't work under some versions of v24 as shell scripts need to be created in the cgi-bin folder in order for the webserver to execute them. If you find the previous startup script doesn't work, try the following:

mdr/m/w/g-i ki tpwwcibn eh -n"!bns\eh 'HM>HA>TTELgie/IL>/ED'nco'BD>\nrmgtrue_ co e #/i/hnco <TL<ED<IL>ofl<TTE<HA>\eh <OY'nva e otrn cmd+ /m/w/g-i/o.h ho x tpwwcibnlgs
www.dd-wrt.com/wiki/index.php/Useful_Scripts 16/27

2/15/13

Useful Scripts - DD-WRT Wiki

and use http://<routerip>/user/cgi-bin/log.sh to access it.

Second Method: Static Generated HTML


Note that it is reported that script-generated content will not be delivered by the web server in v24-RC4 and v24RC5, maybe other versions are affected too (see User-HTML (skript generiert) funzt nicht :( (http://www.ddwrt.com/phpBB2/viewtopic.php?t=25282) in the German forum). If you just get an empty page if using the first method you may use this workaround:

eh -n"!bns\r /m/w/ylghm\eh 'HM>HA>TTELgie(eeae:'> /m/w co e #/i/hnm tpwwsso.tlnco <TL<ED<IL>ofl Gnrtd > tpww cmd+ /m/w/o_e.h ho x tpwwlggns

Save the above code to your startup script and create a cron job for it. To generate a HTML log every 15 minutes you could use this job:
*1 ****ro /m/w/o_e.h /5 ot tpwwlggns

Your router's syslog is now available on http://<routerip>/user/syslog.html and will be updated every 15 minutes (or whatever you've set in the cron job).

Speak Your Signal Strength


I use my WRT in client mode to connect to an access point, but I don't have a particularly good signal quality and I often need to re adjust the position of the WRT and its antenna. Unfortunately my computer is not in sight of the WRT and I had to keep going backwards and forwards from my computer to the WRT making adjustments then checking the signal strength on the screen of my computer. This can take ages to to set up properly, so I decided to get my computer to use the "festival" speech synthesis program to tell me what the current signal level is.
# /i/ah ! bnbs #Ue"etvl t syotlu hwmc sga srnt w hv s fsia" o a u od o uh inl tegh e ae #TeI adeso teWT h P drs f h R i_dr"9.6.." pad=121811 #Teuenm adpswr frteWT h srae n asod o h R ue=ro" sr"ot ps=amn as"di" #Tmoyfl ue t hl tedt fo teWT epr ie sd o od h aa rm h R tpfl=tpwtsau m_ie/m/r.tts eh co eh "h sga lvli:" co Te inl ee seh co eh "h sga lvli"|fsia -ts co Te inl ee s etvl -t wietu ;d hl re o we -ht-sr$sr-ht-asod$asht:/i_drSau_ieeslv.s - $m_iegt -tpue=ue -tppswr=ps tp/$pad/ttsWrls.ieap O tpfl o
www.dd-wrt.com/wiki/index.php/Useful_Scripts 17/27

2/15/13

Useful Scripts - DD-WRT Wiki

sga=ak - ""'atv_iees {pit inl`w F ' /ciewrls/ rn } $m_ie ' tpfl` eh $inl|ak'pit"inl : "\"fr;<j+pit""pit"n} co sga w {rnfSga "t;o(j;+)rnf=;rnf\"' i [ - $inl] ;te f [ n sga ] hn eh $inl|fsia -ts co sga etvl -t es le eh "o ascae"|fsia -ts co Nt soitd etvl -t f i dn oe

This works by using the same process as the 'Status-->Wireless' page i.e. it gets a chunk of data by wget'ing the Status_Wireless.live.asp page from the WRT then running awk to get the relevant chunk of data (the signal strength) and then piping that into the festival speech engine. Now I just run this script and turn up the volume on my computer when I need to move the antenna.

Small Security Script (Firewall)


#/i/h !bns # #Wrig A IdntueEueo smla porm Icntgaat terfnto. ann! s o' s ml r iiir rgas a' urny hi ucin #I yufn awral slto js adi t ti wk. f o id okbe ouin ut d t o hs ii #Ifudtsigsm o testigmnal ta teifa stig wl bekeue on etn oe f h etn auly ht h prg etns il ra ml, #myesm ohr to. ab oe tes o.. # #Ejyyu ehne scrt, no or nacd euiy # #S.Krtl t aiz #if@sr.azehd noue1wltc.e #ht:/awle8.ev tp/dyakr1d.u eh 1>/rcssntiv/cpeh_goeal co po/y/e/p4im_coinr_l eh 1>/rcssntiv/cpeh_goebodat co po/y/e/p4im_coinr_racss eh 1>/rcssntiv/pfrad co po/y/e/p4i_owr #tefloigtoprmtswl beka lateueadaewytolwt mk sne h olwn w aaee il ra t es ml n r a o o o ae es. #co12 >/rcssntiv/prghg_heh eh 04 po/y/e/p4ifa_ihtrs #co52>/rcssntiv/prglwtrs eh 1 po/y/e/p4ifa_o_heh eh 600>/rcssntiv/prghg_heh co 40 po/y/e/p4ifa_ihtrs eh 400>/rcssntiv/prglwtrs co 80 po/y/e/p4ifa_o_heh # eh 1 >/rcssntiv/prgtm co 0 po/y/e/p4ifa_ie eh 5>/rcssntiv/cprtlmt co po/y/e/p4im_aeii eh 1>/rcssntiv/c_ycois co po/y/e/p4tpsnoke eh 0>/rcssntiv/ofeh/cetsuc_ot co po/y/e/p4cn/t1acp_orerue eh 0>/rcssntiv/ofeh/cetrdrcs co po/y/e/p4cn/t1acp_eiet eh 1>/rcssntiv/ofeh/o_atas co po/y/e/p4cn/t1lgmrin eh 1 >/rcssntiv/eg/t1lctm co 0 po/y/e/p4niheh/okie eh 0>/rcssntiv/ofeh/rx_r co po/y/e/p4cn/t1poyap eh 5 >/rcssntiv/eg/t1g_tl_ie co 0 po/y/e/p4niheh/csaetm # #Tefloigetisscr tels btadpoiea h olwn nre eue h at i n rvd #mdrt poeto aantmni-h-ideatcs oeae rtcin gis a-ntemdl tak. # eh 0>/rcssntiv/ofeh/edrdrcs co po/y/e/p4cn/t1sn_eiet
www.dd-wrt.com/wiki/index.php/Useful_Scripts 18/27

2/15/13

Useful Scripts - DD-WRT Wiki

eh 0>/rcssntiv/ofeh/euerdrcs co po/y/e/p4cn/t1scr_eiet eh 1>/rcssntiv/cpinr_ou_ro_epne co po/y/e/p4im_goebgserrrsoss eh 5>/rcssntiv/gpmxmmesis co po/y/e/p4im_a_ebrhp eh 2>/rcssntiv/gpmxmf co po/y/e/p4im_a_s eh 12 >/rcssntiv/c_a_rhn co 04 po/y/e/p4tpmxopas eh 2>/rcssntiv/c_y_ere co po/y/e/p4tpsnrtis eh 2>/rcssntiv/c_yakrtis co po/y/e/p4tpsnc_ere eh 1>/rcssntiv/c_br_noefo co po/y/e/p4tpaoto_vrlw eh 1 >/rcssntiv/c_i_ieu co 0 po/y/e/p4tpfntmot eh 0>/rcssntiv/ot/eietnme co po/y/e/p4ruerdrc_ubr eh 1>/rcssntiv/ofalr_itr co po/y/e/p4cn/l/pfle eh 1>/rcssntiv/ofeh/pfle co po/y/e/p4cn/t1r_itr eh 1>/rcssntiv/c_ycois co po/y/e/p4tpsnoke eh 0>/rcssntiv/ofalacp_orerue co po/y/e/p4cn/l/cetsuc_ot eh 6 >/rcssntiv/pdfuttl co 1 po/y/e/p4i_eal_t #DSpoeto b tekn tetmot o rtcin y waig h ieus eh "80 >/rcssntiv/c_eplv_ie co 10" po/y/e/p4tpkeaietm eh "">/rcssntiv/c_idwsaig co 0 po/y/e/p4tpwno_cln eh "">/rcssntiv/c_ak co 0 po/y/e/p4tpsc #W peedt b aCekon frwl o WnosX e rtn o e hcpit ieal n idw P eh 49 8304934>po/y/e/p4tpre co 06 78 140 /rcssntiv/c_mm eh 49 8304934>po/y/e/p4tpwe co 06 78 140 /rcssntiv/c_mm #Cekntokoela (xlctcneto ntfcto) hc ewr vrod epii ogsin oiiain eh 1>/rcssntiv/c_c co po/y/e/p4tpen #Cag pr rnefroton tafc hne ot ag o ugig rfi eh "00 600 >/rcssntiv/plclpr_ag co 300 00" po/y/e/p4i_oa_otrne #Cag dfutqeesz hne eal uu ie #Mdfe frD-R bcueo msigpo etis oiid o DWT eas f isn rc nre eh 49 >/rcssntiv/pcntakmx co 06 po/y/e/p4i_onrc_a #LDsga febc we srp ed E inl edak hn cit ns sep1 le gi eal 3 po nbe sep1 le gi dsbe3 po ial sep1 le gi eal 3 po nbe sep1 le gi dsbe2 po ial sep1 le gi eal 2 po nbe sep1 le gi dsbe2 po ial #I yudlk t dsbetewbitraeucmet f o' ie o ial h e nefc nomn #tefloigln h olwn ie #ill htd klal tp

Attention, you might have to change eth1 to the actual WAN (external) interface. Installation is pretty simple: 1. Log on to your WRT 2. type c / f s d jf 3. type v s c s (or any other name) and enter the script i e.h
www.dd-wrt.com/wiki/index.php/Useful_Scripts 19/27

2/15/13

Useful Scripts - DD-WRT Wiki

4. 5. 6. 7.

Connect to your WRT via web browser, page Administration:Commands Enter the script name (sec.sh) into the command field Click on "Save Startup" Reboot router

As a simple test try to ping your router. You should get no response otherwise you have to find the error.

Secure remote management for a WAP


Regards to the help of phusi0n (http://www.dd-wrt.com/forum/profile_sec.php?mode=viewprofile&u=7994) ddwrt guru and of HP (http://forum.ubuntu-fr.org/profile.php?id=3670) from ubuntu-fr This requires a recent >12533* to prevent milw0rm and to have the Disable "Allow any remote IP" feature. Also requires you have set the necessary port forwards in the gataways(s) on the path.

itbe - IPT- tp- DO pals I NU p c j RP itbe - IPT- `va gtlniad``va gtlnntak - tp- mliot-dot `va pals I NU s nrm e a_pdr/nrm e a_ems` p c m utpr -prs nrm itbe - IPT- `va gtrmt_p|ak'pit}`- tp- mliot-dot `va gtsh pals I NU s nrm e eoei w {rn ' p c m utpr -prs nrm e sd

This allows the lowest (first) IP address set in the "Allow any remote IP" feature to connect to the https and ssh servers in the WAP (you just need the password and/or the private key) ;) . In addition, all LAN ip are allowed to do the same. Althought the "Allow any remote IP" feature doesn't work at this time when the router is set as a WAP (LAN-LAN link to the gateway, so no routing and WAN disabled, dhcp off and other stuff), this convenient script will use the first "remote_ip" you set in the GUI (wether the feature is enabled or not, as long as you stored at least one IP) and will follow the changes you could do to its static lan ip/netmask and ssh server port. Now you have full benefit of the GUI from a remote static IP and can leave the forwards enabled on the path. EDIT 2011/06/25: even with elder releases, the remote IP can be hardcoded in the script, replacing `nvram get remote_ip | awk '{print }'` by the actual IP. --Bib 14:03, 17 May 2010 (CEST) EDIT 2011/08/16: I slightly change this script to make it work when the WAP's LAN IP is set through dhcp instead of static:

itbe - IPT- tp- DO pals I NU p c j RP I_A=icni b0|ge ie |ct-:-2|ct-''-1 PLN`fofg r rp nt u d f u d f` MK`fofgb0|ge ie |ct-:-4 S=icni r rp nt u d f` itbe - IPT- $I_A}$S - tp- mliot-dot `va gtsh_ot,4,0- ACP pals I NU s {PLN/MK p c m utpr -prs nrm e sdpr`438 j CET itbe - IPT- `va gtlniad``va gtlnntak - tp- mliot-dot `va pals I NU s nrm e a_pdr/nrm e a_ems` p c m utpr -prs nrm itbe - IPT- `va gtrmt_p|ak'pit$}`- tp- mliot-dot `va gts pals I NU s nrm e eoei w {rn 1' p c m utpr -prs nrm e s

Remove the port 80 after you have backed up your conf. --Bib
www.dd-wrt.com/wiki/index.php/Useful_Scripts 20/27

2/15/13

Useful Scripts - DD-WRT Wiki

Directory Listing for DD-WRT Micro


Since the Micro version of DD-WRT doesn't provide a ls command, here is a very simple script to list directory contents
#/i/h !bns fls`co* ie=eh ` frxi $ie;d o n fls o i [- $ ] te f d x ; hn eh - "x " co n $/ es le eh - "x" co n $ f i dn oe eh co

See the Telnet/SSH_and_the_Command_Line (http://www.ddwrt.com/wiki/index.php/Talk:Telnet/SSH_and_the_Command_Line) Talk page for other variants.

Reset Wireless Radio


This script solves an intermittent problem on my NetGear WNDR3300 wireless N radio. Every few hours, the wireless N radio stops broadcasting and cannot be seen by wireless clients. Bringing the wireless interface down and then back up resolves the issue. This script pings a wireless client, in my case, a WET610N wireless bridge that should always remain up and only connects to the wireless N radio. If the ping fails twice within a given time, it brings the interface down and then back up. To get this to work on Atheros hardware, replace the two 'wl - i'... comands with 'ifconfig'... (e.g., this fixes wifi dropouts on my Buffalo WZR-HP-G300NH)
#/i/h !bns #Ti srp sle a itrietpolmo m hs cit ovs n nemtn rbe n y #NterWD30 wrls Nrdo eGa NR30 iees ai. Eeyfw vr e #hus or, tewrls Nrdososbodatn h iees ai tp racsig #adcno b se b wrls cins n ant e en y iees let. Bign rnig #tewrls itraedw adte bc u h iees nefc on n hn ak p #rsle teise eovs h su. Ti srp pnsa hs cit ig #wrls cin,i m cs,aWT1Nwrls iees let n y ae E60 iees #big ta sol awy rmi u adol rde ht hud las ean p n ny #cnet t tewrls Nrdo oncs o h iees ai. I te f h #pn fistiewti agvntm,i ig al wc ihn ie ie t #big teitraedw adte bc u. rns h nefc on n hn ak p #Awrls cin ta sol awy b u iees let ht hud las e p CIN_P12183.5 LETI=9.6.520 #Wrls itraeta dsper iees nefc ht iapas ITRAE`va gtw0inm` NEFC=nrm e l_fae #scnst wi atrfie pn t tyaan eod o at fe ald ig o r gi FI_GI=0 ALAAN1
www.dd-wrt.com/wiki/index.php/Useful_Scripts 21/27

2/15/13

Useful Scripts - DD-WRT Wiki

#scnsbtencek eod ewe hcs CEKEEY6 HC_VR=0 #atrccig wi ti mn scns fe yln, at hs ay eod ATRCCE30 FE_YL=6 #Cin ms b u bfr satn mi lo let ut e p eoe trig an op wietu hl re d o i pn - 1$CIN_P >dvnl f ig c {LETI} /e/ul te hn eh "{LETU}o -bgnn mi lo" co $CIN_P k eiig an op bek ra f i dn oe #mi srp an cit wiesep$CEKEEY hl le {HC_VR} d o i pn - 1$CIN_P >dvnl f ig c {LETI} /e/ul te hn eh "{LETI}o" co $CIN_P k es le eh "{LETI}dopdoe co $CIN_P rpe n" sep$FI_GI} le {ALAAN i !pn - 1$CIN_P >dvnl f ig c {LETI} /e/ul te hn eh "{LETI}dopdto snigrsatn $ITRAE" co $CIN_P rpe w, edn etrig {NEFC} #o Ahrshrwr isedue icni $ITRAE dw n teo adae nta s: fofg {NEFC} on w - $ITRAE dw l i {NEFC} on sep3 le #o Ahrshrwr isedue icni $ITRAE u n teo adae nta s: fofg {NEFC} p w - $ITRAE u l i {NEFC} p sep$ATRCCE le {FE_YL} f i f i dn 2& oe >1

Display Connection Counts Per IP


For local IP's

frii `rp0 /rcntap|ct- ''-1;d eh "icneto cut $ge - $ /rcnt o n ge x po/e/r u d f` o co $ oncin on: (rp c i po/e/

Foa all IP's

frii `rp0 /rcntap|ct- ''-1;d eh "icneto cut $ge - $ /rcnt o n ge x po/e/r u d f` o co $ oncin on: (rp c i po/e/

L2TP Fix for HOT users (obsolete)


Script for HOT users at Israel who can't connect using L2TP because DD-WRT default setting for "refuse
www.dd-wrt.com/wiki/index.php/Useful_Scripts 22/27

2/15/13

Useful Scripts - DD-WRT Wiki

pap=yes" while HOT setting is the opposite. Fix was risen by aviad_ra @ http://www.ddwrt.com/phpBB2/viewtopic.php?t=17002&postdays=0&postorder=asc&highlight=l2tp&start=15 This is a cleaned up version of the same script. Add the script as a startup script.

#/i/h !bns wie:;d hl o lge - - lcl.oie- LT "aiaig\rfs pp=n\" ogr s p oa0ntc t 2P Vldtn "eue a o" wie[ - /m/ltdx2p.of& - "ct/m/ltdx2p.of|ge "euepp=ys hl [ e tpx2p/ltdcn & n `a tpx2p/ltdcn rp rfs a e d o lge - - lcl.oie- LT "i i nee a \rfs pp=ys" ogr s p oa0ntc t 2P Fx s edd s "eue a e\" ct/m/ltdx2p.of|sds"euepp=ys/rfs pp=n"g>/m/ltd a tpx2p/ltdcn e /rfs a e""eue a o/ tpx2p m /m/ltdx2p.oftp/m/ltdx2p.of v tpx2p/ltdcn.m tpx2p/ltdcn lge - - lcl.oie- LT "ltdcn hsbe fxd ogr s p oa0ntc t 2P x2p.of a en ie" sep5 le dn oe sep3 le 0 dn& oe

Email Bandwidth Usage Daily


This script will email you with the previous day's and total month's bandwidth usage. Edit it with your sendmail SMTP info. More in-depth examples Original Forum Topic (http://www.dd-wrt.com/phpBB2/viewtopic.php?p=476631#476631)
#/i/h !bns fcmi( { n_al) sb=$" uj"1 mg"2 s=$" i [- "3 - "(inm $) =""] te lgie"tplsmi.o" es lgie"3;f f z $" o $drae 3" . ; hn ofl=/m/atallg; le ofl=$" i

snmi -"mpcmatnt -"edrcmatnt -"DWT -"ocs.e"-"sb"-"mg m edal Sst.ocs.e" fsne@ocs.e" FD-R" dcmatnt s$uj m$s" e }

#as tepeiu dyadmnhyttl adsn a eal Pre h rvos a n otl oas n ed n mi af"f"#ewr wraon f=af kyod okrud ya=(ae- % - $($dt +s -840)+d dy$dt D s d ( (ae %) 60) %) yo=(ae- % - $($dt +s -840)+raf%-Y mn$dt D s d ( (ae %) 60) t$f-m%) i [$dt +d -q1] te mns=Ls Mnh;es mns=Mnht Dt" f f (ae %) e ; hn omg"at ot" le omg"ot o ae; i mg$nrmgt$mn|ak'pit$$dy,$F'|sd'/(^]\:(^]\ \\[:*)\[]*)/ s=(va e yo w {rn 'ya' N} e s\[:*)\[ *) [(^]\:(^]\] fcmi "adit Rpr""mg "tpbmi.o" n_al Bnwdh eot $s" /m/wallg

Update Allowed Remote IP Range by DNS lookup


If you are allowing Remote Access to manage your router from a remote location, this script will update the IP address range via a DNS lookup, in the event that the IP address assigned to the remote location changes. For home users, an account with a DDNS service such as DynDNS will work.

www.dd-wrt.com/wiki/index.php/Useful_Scripts

23/27

2/15/13

Useful Scripts - DD-WRT Wiki

#aibe Vrals # #uea1 mnt itra s 0 iue nevl ITRA=0 NEVL60 #e DSetyt cek st N nr o hc RMT_N=CAG T YU DS EOEDS*HNE O OR N*

#### #### Bd o Srp ######## oy f cit ####### wiesep$NEVL hl le ITRA d o #Strmt I vral e eoe P aibe RMT_P`ig- 1$EOEDS|ge "PN"|ct-3-""|ct-2-""|ct-1-"" EOEI=pn c RMT_N rp ^IG u f d u f d( u f d)` #e edn ottvral t b oemr ta tels otto termt ades St nig ce aibe o e n oe hn h at ce f h eoe drs ltEDN_CE=eh $EOEI |ct-4-""+ e NIGOTT`co RMT_P u f d.`1 #eemn tecretI adesta' ue frrmt mngmn dtrie h urn P drs hts sd o eoe aaeet CRETAMNI=nrmgtrmt_p|ak'pit$}` URN_DI_P`va e eoei w {rn 1' ##I termt I hscagd te cag teammI stig # f h eoe P a hne, hn hne h di P etn i ["CRETAMNI"! "RMT_P ] te f $URN_DI_P = $EOEI" ; hn #ofgr WPt alwti I adest cnetrmtl cniue A o lo hs P drs o onc eoey nrmstrmt_p"RMT_P$NIGOTT va e eoei=$EOEI EDN_CE" #aenrmstig sv va etns nrmcmi >/e/ul2& va omt dvnl >1 f i dn oe ##Edo srp # n f cit

Other Useful Misc. Scripts


These scripts will be executed through either SSH or Telnet. Once logged into you router via one of these methods, the following are quite useful:

d -Dsly mutdetra dvcs sc a UBsoae f ipas one xenl eie, uh s S trg. Ued - t seteata sz vle i s f h o e h cul ie aus n

mut-Mut a etra dvc sc a aUBHD(xml: mut/e/cihs0bs/agt/u0p on ons n xenl eie uh s S D Eape on dvss/ot/u0tre0ln/

mut-bn -Bnsa oddrcoyt anwdrcoy(xml:mut-bn /m/n/m)-Tp on -id id n l ietr o e ietr Eape on -id tpmttp ye

www.dd-wrt.com/wiki/index.php/Useful_Scripts

24/27

2/15/13

Useful Scripts - DD-WRT Wiki

uon -Umut teetra dvc mut nons h xenl eie

tp-Dsly alrnigpoessicuigteCUuae Mmr Uaeads o o ipas l unn rcse nldn h P sg, eoy sg n o n

deg|mr -Wl dslyRue ifrainoesgeta atm (emnlwno sz)adb hti ms oe il ipa otr nomto n emn t ie tria idw ie n y it

nttt-n-Wl dslyalicmn/ugigcnetos esa a il ipa l noigoton oncin

p -Wl dslyalrnigpoess-Uep -hl t dslymr otos s il ipa l unn rcse s s -ep o ipa oe pin.

fe -Dsly cretmmr saitc,adb ue wt etnin (xml:fe -)-Uefe re ipas urn eoy ttsis n e sd ih xesos Eape re l s re ?

ct-Vr,vr ueu adcndslyaliptotu msae fo terue" (xml:ct/m/ a ey ey sfl n a ipa l nu/upt esgs rm h otr Eape a tpv

nrmso -Dsly eeynrmvral adaalbenrmsae va hw ipas vr va aibe n vial va pc

nrmst-Sttevleo a nrmvral (xml:nrmstr_ieal"cohlo) va e e h au f n va aibe Eape va e cfrwl=eh el"

nrmust-Dltsa nrmvral,ntol iscnet(xml:nrmusttaf1-10-ue va ne eee n va aibe o ny t otn Eape va ne rf-321 sf

nrmcmi -Cmisnrmvralst tefahci va omt omt va aibe o h ls hp

rbo -Rbosterue,adms b ue atra nrmcmi eot eot h otr n ut e sd fe n va omt

c /fs-Cagst tejf drcoy d jf hne o h fs ietr

c /n -Cagst temutddrcoy d mt hne o h one ietr

c /p -Cagst te/p drcoy d ot hne o h ot ietr

These commands can also be be bound. (Example: cd /mnt/opt/etc)


NT: Tefloigcmad aeue we teaoecmad hv be eeue OE h olwn omns r sd hn h bv omns ae en xctd

www.dd-wrt.com/wiki/index.php/Useful_Scripts

25/27

2/15/13

Useful Scripts - DD-WRT Wiki

mdr-Mksadrcoy i wiho cus yune t seiy(xml:mdr/n/fs T mutt ki ae ietr, n hc f ore o ed o pcf Eape ki mtjf) o on h

rdr-Rmvsteseiiddrcoy mi eoe h pcfe ietr

r -Rmvsadrcoy(xml:c /p te r -f* - Rmvsteotdrcoy m eoe ietr Eape d ot hn m r ) > eoe h/p ietr

klal-kl aseii poes(xml:klalssod ill il pcfc rcs Eape ill ylg)

sep-Cue tepoest dlysatpfrseiidtm (xml:sep2 & /p/i/uyo s le ass h rcs o ea tru o pcfe ie Eape le 0 & otbnbsbx w

con-Cag teonrado gopo ec FL t ONRado GOP-Tp con-hl frsrn hw hne h we n/r ru f ah IE o WE n/r RU ye hw -ep o tig

cmd-Alw priin cagn o drcois(xml:cmd+ /fseccni/ -Te+ srn ho los emsos hnig n ietre Eape ho x jf/t/ofg) h x tig

sosrie-Sosteseiidsrie(xml:sosrieun)-Rpaeso wt satt sat tpevc tp h pcfe evc Eape tpevc pp elc tp ih tr o tr

See Also
LED Scripts Startup Scripts Script Examples Retrieved from "http://www.dd-wrt.com/wiki/index.php/Useful_Scripts" Categories: Scripts | Tutorials

Article | Discussion | Edit | History What links here | Related changes | Upload file | Special pages
www.dd-wrt.com/wiki/index.php/Useful_Scripts 26/27

2/15/13

Useful Scripts - DD-WRT Wiki

| Permanent link Print as PDF This page was last modified 07:36, 12 November 2012. This page has been accessed 628,696 times. About DD-WRT Wiki | Disclaimers | Powered by MediaWiki | Design by Paul Gu

www.dd-wrt.com/wiki/index.php/Useful_Scripts

27/27

Vous aimerez peut-être aussi