Script examples
From DD-WRT Wiki
Revision as of 15:27, 30 September 2005 (edit) 69.236.142.248 (Talk) (→bypass Idle Time - - small change to header/title and text) ← Previous diff |
Revision as of 16:20, 8 October 2005 (edit) (undo) 85.181.43.248 (Talk) Next diff → |
||
Line 59: | Line 59: | ||
sleep 300; # wait 5 minutes | sleep 300; # wait 5 minutes | ||
done; | done; | ||
+ | </pre> | ||
+ | |||
+ | ====How many connections are open for each IP?==== | ||
+ | |||
+ | This is handy for finding that person in your LAN whose P2P software opens many hundreds of connections, making the network slow for everybody. | ||
+ | |||
+ | <pre> | ||
+ | sed -n 's%.* src=\(192.168.[0-9.]*\).*%\1%p' /proc/net/ip_conntrack | sort | uniq -c | ||
</pre> | </pre> |
Revision as of 16:20, 8 October 2005
Contents |
Which IPs and hostnames are used for wireless clients?
Note: Only work if you get an IP from DHCP
# mkdir -p /tmp/www while [ 1 ]; do wl assoclist | awk '{print$2}' > /tmp/assocLIST # echo "<meta http-equiv="refresh" content="10"><b>Hostnames and IPs of WLAN clients</b> (last update: $(date))<p>" > /tmp/www/wlan.html while read assocLINE do dumpleases | grep -i $assocLINE | awk '{print "Hostname: " $1, "MAC: " $2, "IP: " $3}' # echo "<br>"; done < /tmp/assocLIST # >> /tmp/www/wlan.html sleep 10; done;
Output:
Hostname: tp MAC: 01:81:18:3d:49:5e IP: 192.168.2.101
You can change the order of "$1, $2, $3" or cut-out:
....awk '{print $1,$3}'
Output:
tp 192.168.2.101
if you want to show this in a browser remove the # and use: http://routerIP/user/wlan.html
To booting on startup see Startup Scripts
How can I protect this file? I want to allow showing this only if you are logged in the web interface! Please write it here, thanks
Keep ISP from disconnecting due to lack of traffic
Some Internet Service Providers will drop the connection if there is no traffic for some period of time (Idle Time-Out). With these script you can prevent this.
while [ 1 ]; do ping -c 5 www.example.com > /dev/null # ping 5 packets sleep 300; # wait 5 minutes done;
If this does not work (providers ignores ICMP packets as traffic) use:
while [ 1 ]; do wget http://www.example.com/ -O /tmp/index -q # download index file sleep 300; # wait 5 minutes done;
How many connections are open for each IP?
This is handy for finding that person in your LAN whose P2P software opens many hundreds of connections, making the network slow for everybody.
sed -n 's%.* src=\(192.168.[0-9.]*\).*%\1%p' /proc/net/ip_conntrack | sort | uniq -c