Script to sort static leases

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Goto page Previous  1, 2
Author Message
micangelo
DD-WRT Novice


Joined: 09 Jan 2021
Posts: 1

PostPosted: Mon Jan 18, 2021 1:22    Post subject: DO NOT USE IN WEB GUI Reply with quote
I ran this command in administration/commands and it completely erased my 40-ish static leases. I'm going to go kill myself now.
Sponsor
rknox
DD-WRT Novice


Joined: 07 Jan 2011
Posts: 15
Location: San Jose, CA

PostPosted: Fri Jun 09, 2023 3:53    Post subject: Static Leases Script Reply with quote
Paint wrote:
smeisner wrote:
A coworker fixed my script. Here's a better version...all on 1 line...also it properly sorts the IP addresses as numeric values.

Code:
nvram set static_leases="`nvram get static_leases | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)/.\1./g' | tr ' ' '\n' | sort -n -k2,2n -k3,3n -k4,4n -k5,5n -t. | tr '\n' ' ' | sed 's/\.\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\./\1/g' | sed 's/^ //'; echo`"


thanks for this. Cleaned up my dnsmasq static lease list.

-----edit----

can someone create a similar script to this to reorder port forwards by port and hostname? Thanks!


Wow, came across this by accident. I have spent hours satisfying my OCD by re-ordering / re-entering static leases. I ran it from telnet - worked first time and Services screen updated immediately. Fantastic!!
xmadnet
DD-WRT Novice


Joined: 25 Apr 2015
Posts: 6

PostPosted: Sat Feb 01, 2025 9:23    Post subject: Sorting forward_spec Reply with quote
Hi, Try using the same script to sort forward_spec on (Firmware: DD-WRT v3.0-r58389 std (09/20/24) ; Netgear R8000)
Code:
nvram set forward_spec ="`nvram get forward_spec | sed 's/\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)/.\1./g' | tr ' ' '\n' | sort -n -k2,2n -k3,3n -k4,4n -k5,5n -t. | tr '\n' ' ' | sed 's/\.\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\./\1/g' | sed 's/^ //'; echo`"

Script seems to work (nvram get forward_spec | sed ....) but if I store result in forward_spec it clears it ?
Any idea
BR
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 386

PostPosted: Sun Feb 02, 2025 4:35    Post subject: Reply with quote
Did you try without the space before the equal operator?
Goto page Previous  1, 2 Display posts from previous:    Page 2 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum