Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - toschulz

#1
I'm going to say that I would very much like to have a way to delete a lease from the web interface.  I know it's not the intended use case, but I use Opnsense as a frontend as DHCP server for a school of 500 students.  As others have said, there are times when it's really useful to delete a lease.   For the time being, I've been using the following script to remove leases from a command prompt 

#!/bin/bash

removeLease()
{
        if [ "${1}" == "" ]
        then
                echo -e "\nPlease supply the IP of the lease you want to remove"
                echo -e "\tex: rm_lease.sh <IP>\n"
                return 10
        fi
        echo "Remove IP: ${1}"
        if [ "`cat /var/db/dnsmasq.leases | egrep ${1}`" != "" ]
        then
                echo -e "Found lease for: ${1}\n"
                service dnsmasq stop
                sleep 1
                cat /var/db/dnsmasq.leases | egrep -v ${1} > /tmp/dnsmasq.leases
                cp /tmp/dnsmasq.leases /var/db/dnsmasq.leases
                service dnsmasq start
                if [ "`cat /var/db/dnsmasq.leases | egrep ${1}`" == "" ]
                then
                        echo -e "\nRemoved lease: ${1}\n"
                fi
        else
                echo -e "No lease for ${1} found\n"
        fi
}

removeLease ${1}