Joined: 01 Mar 2009 Posts: 3 Location: Kiel, Germany
Posted: Mon Mar 02, 2009 10:18 Post subject: Table of static DHCP-Leases
Hi,
is there a possibillity to edit the table of static DHCP-Leases (accesible via the Services-tab in the GUI) easily with the command-line or to upload a predefined *.txt-file? The point is, that it is quite nasty (and boring) to fill every single field in the table manually when there are many changes at one time (especially when you are doing copy& paste from e.g. MS Excel).
Thanks for helping me,
Holger
# changed to SCP upload because length of command that can be
# used in ssh.exec! seems to be limited
vpn_push = <<-END
nvram set dnsmasq_enable=1
nvram set dns_dnsmasq=1
nvram set auth_dnsmasq=1
nvram set dhcp_start='#{network.dhcp_start}'
nvram set dhcp_num='#{network.dhcp_num}'
nvram set dnsmasq_options='#{dhcp_options}'
END
scp.upload!(StringIO.new(vpn_push), "/tmp/vpn_push.sh")
printf(".")
$stdout.flush
ssh.exec!("/bin/sh /tmp/vpn_push.sh")
ssh.exec!("rm /tmp/vpn_push.sh")
printf(".")
$stdout.flush
ssh.exec!("nvram commit") do |ch, res|
raise "Failed to commit to nvram" unless res
printf("c")
$stdout.flush
end
scp.upload!(StringIO.new(str), "/tmp/dnsmasq.conf")
ssh.exec!("rm /tmp/dnsmasq.leases")
printf(".")
$stdout.flush
ssh.exec!("killall dnsmasq")
printf(".")
$stdout.flush
ssh.exec!("dnsmasq --conf-file=/tmp/dnsmasq.conf")
puts(". done.")
end
end
Basically, what it does is:
Generate a new configuration file for dnsmasq
Upload that file with scp to the router
Delete the old leases file (required if leases change)
Restart dnsmasq with new configuration
The only problem is that you need to have a short lease time because clients do not know about any ip changes until their lease expires. I have set LEASE_TIME to one hour.
I get all that but I'm looking for an improvement to the GUI. Like I orginally pointed out, every other SOHO router I've ever used, and there have been many, allow you to automatically populate a DHCP reservation from the connected clients table. I REALLY cut's down on typing and errors. It's very useful. How do we request features for D-WRT? Is there a thread for that discussion?
Thanks folks. BTW, I can't upload yet, too few posts, but I wrote a shell script to parse a hosts-like file that will populate the static_leases. If anyone wants it, PM me.