🖥️dhcpd

➡️This is a command-line reference manual for commands and command combinations that you don’t use often enough to remember it. This cheatsheet explains the dhcpd command with important options and switches using examples.

▁ ▂ ▃ ▄ ꧁ 🔴☠ COMMANDLINE-KUNGFU WITH CHEATSHEETS ☠🔴꧂▅ ▃ ▂ ▁

#                ██████╗ ██╗  ██╗ ██████╗██████╗ ██████╗ 
#                ██╔══██╗██║  ██║██╔════╝██╔══██╗██╔══██╗
#                ██║  ██║███████║██║     ██████╔╝██║  ██║
#                ██║  ██║██╔══██║██║     ██╔═══╝ ██║  ██║
#                ██████╔╝██║  ██║╚██████╗██║     ██████╔╝
#                ╚═════╝ ╚═╝  ╚═╝ ╚═════╝╚═╝     ╚═════╝ 
                                                        
                                                       
# Alle Leases - öfter vorkommende IP's ausgefiltert
grep ^lease /var/lib/dhcp/dhcpd.leases | cut -d ' ' -f 2 | sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n | uniq

# Alle Leases, Einfacher jedoch ohne doppelte IP Ausfilterung 
egrep "^lease" /var/lib/dhcp/db/dhcpd.leases |awk '{ print $2 }'

# Syntaxcheck, dann DHCP Stoppen, alles Leases Nullen, anschließend DHCP neustart und statuscheck (ops läuft)
/etc/init.d/dhcpd check-syntax
systemctl dhcpd stop
:> /var/lib/dhcp/db/dhcpd.lease
systemctl dhcpd start
systemctl dhcpd status

#!/bin/bash
# dhcp_pretty.sh
# Awk script to make the dhcp.leases more readable 
awk ' { out = ""} \
{ $1=="lease"||$1=="client-hostname" ? out=" " $2 : out=out } \
{ $1=="binding"||$1=="hardware" ? out= " " $3: out=out } \
{ $1=="ends"? out=" " $3 " " $4: out=out } \
{ $1=="}"? out="\n": out=out } \
{ printf out," " }' dhcpd.leases \
| grep active \
| sed -e s/'[{};" ]'/\ /g  \
| awk '{ printf "%-15s %-17s %-10s %-5s\n", $1, $5, $2, $3 }'

########################
awk 'BEGIN { RS="}" } { for(i=1;i<=NF;i++) if ($i~"192.168") print $2,$i }' /etc/dhcpd.conf|sed 's/;//g'|sort -n -t. -k4
###############################

#==============================##==============================#
# CMD dhcpd						       #
#==============================##==============================#
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░

  █║▌│║█║▌★ KALI ★ PARROT ★ DEBIAN 🔴 PENTESTING ★ HACKING ★ █║▌│║█║▌

              ██╗ ██╗ ██████╗  ██████╗ ██╗  ██╗███████╗██████╗
             ████████╗██╔══██╗██╔═══██╗╚██╗██╔╝██╔════╝██╔══██╗
             ╚██╔═██╔╝██║  ██║██║   ██║ ╚███╔╝ █████╗  ██║  ██║
             ████████╗██║  ██║██║   ██║ ██╔██╗ ██╔══╝  ██║  ██║
             ╚██╔═██╔╝██████╔╝╚██████╔╝██╔╝ ██╗███████╗██████╔╝
              ╚═╝ ╚═╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚══════╝╚═════╝

               █║▌│║█║▌ WITH COMMANDLINE-KUNGFU POWER █║▌│║█║▌

░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░