Synchonize DHCP leases from a CSV-file to a dd-wrt router

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Author Message
dkuenzel
DD-WRT Novice


Joined: 29 Apr 2012
Posts: 1
Location: W. Germany

PostPosted: Sun Apr 29, 2012 22:51    Post subject: Synchonize DHCP leases from a CSV-file to a dd-wrt router Reply with quote
Hello Folks!

First I would like to thank the Forum for the numerous suggestions in learning how to work with my dd-wrt router (wrt54). There are a lot of valuable Threads here!

I thought it would be time now to return something to the community and maybe help some people out there simplifying their management of the dd-wrt router. Smile

My Quest:
Since I manage my DHCP-leases and MAC-adresses in a OpenOffice Table I tried to find an easy way to synchronize that table with the router's nvram. It should prevent me from entering all the data manually into the dd-wrt's gui. Additionally it should synchonize my MAC-Adress filter with the Table, so that new Adresses are added to the Filter, and unused ones are removed.

My Solution:
I found it to be comfortable to export an CSV-file from my OpenOffice table, which then could be parsed into the router's nvram by an BaSH script.
The creation/activation of the MAC-filter is optional, so the script can also be used if only IP-leases should be transfered to the router.
It doesn't matter if you use OpenOffice for IP-adress organizing, the only thing that is important is, that the resulting CSV-file is in the right format

Usage
Syntax:
wrt-leases+macs.sh CSVFILE ROUTERIP

The CSV-File's tuples should be in the following format:
Code:
"MAC=NAME=IP",VLAN

--> Starting with build 13832 the format has changed to the following:
Code:
"MAC=NAME=IP=LEASETIME",VLAN


MAC = MAC-Adress of device
NAME = System Name of Device (be careful, don't use special characters, etc.)
IP = DHCP IP-adress for the Device
>>>OPTIONAL<<<
VLAN = If number equals MACFILTER variable, include the MAC-adress in the MAC filter.
This is thought to automate the process of adding devices in a WLAN-VLAN to the Mac filter List. By default the tuple's MAC-adresses with VLAN=2 are added to the MAC filter list. If there are no matches or the parameter is empty no MAC-list is transfered to the router.

Example (With VLAN parameter):
Code:
"02:41:E3:5D:66:D7=testdevice=192.168.1.7",2

Example (Without VLAN parameter):
Code:
"02:41:E3:5D:66:D7=testdevice=192.168.1.7"


I added the script, an example OpenOffice-table and an example CSV-file to this post.
To get the CSV from the OpenOffice-table you have to save the sheet "leases.csv" to an CSV-file.
The default number of the VLANs which should be added to the MAC-filter, by default the router is configured to allow only IPs in the list. The options can be customized in the script.

Defaults:
VLAN=2
wl0_macmode="allow"
wl0_macmode1="other"

If you have annotations to my approach or find any bugs in this script, I would be greatful to discuss them.

Kind regards,

David


EDIT 05.05.2011: Fixed a Bug in the Script and simplyfied the Process a bit. Uploaded a new version of the script.

_________________
||bashing the cat with multiple pipes||
Sponsor
Display posts from previous:    Page 1 of 1
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