I have a dhcpd.leases file with the following:
lease 172.231.100.152 {
starts 2 2017/11/14 14:50:41;
ends 2 2017/11/14 15:20:41;
tstp 2 2017/11/21 15:05:41;
cltt 2 2017/11/14 14:50:41;
binding state active;
next binding state expired;
lease 172.231.100.152 {
starts 2 2017/11/14 14:50:41;
ends 2 2017/11/14 15:20:41;
tstp 2 2017/11/21 15:05:41;
cltt 2 2017/11/14 14:50:41;
binding state active;
next binding state expired;
lease 172.231.100.152 {
starts 2 2017/11/14 14:50:41;
ends 2 2017/11/14 15:20:41;
tstp 2 2017/11/21 15:05:41;
cltt 2 2017/11/14 14:50:41;
binding state free;
next binding state expired;
lease 172.231.100.151 {
starts 2 2017/11/14 14:50:41;
ends 2 2017/11/14 15:20:41;
tstp 2 2017/11/21 15:05:41;
cltt 2 2017/11/14 14:50:41;
binding state active;
next binding state expired;
lease 172.231.100.152 {
starts 2 2017/11/14 14:50:41;
ends 2 2017/11/14 15:20:41;
tstp 2 2017/11/21 15:05:41;
cltt 2 2017/11/14 14:50:41;
binding state free;
next binding state expired;
As you may know in this file some leases are recorded multiple times. I need a solution to only grep out a unique IP addresses RANGE using the 172.231.100 BUT only the ones that have a binding state of active. I am aware there are scripts out there that do this for you with DHCP but ours is not working atm and a command line solution for this would be great. Note the "binding state " line will always be the 6th line from the "lease" line.