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: 12

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!!
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