Koozali.org: home of the SME Server

Reading DHCP assignments in SME

Offline morrislex

  • *
  • 7
  • +0/-0
Reading DHCP assignments in SME
« on: November 23, 2007, 04:49:17 PM »

Does anyone know what command I would use to read DHCP addresses given out by my SME.

ALso is there a list of "run" or application files with SME that come with the distro that can be ran?




Bill

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Reading DHCP assignments in SME
« Reply #1 on: November 23, 2007, 05:10:28 PM »
Does anyone know what command I would use to read DHCP addresses given out by my SME.

Code: [Select]
cat /var/lib/dhcp/dhcpd.leases

I think, though, that somebody developed a contrib which can display the leases via the server-manager.

Quote
ALso is there a list of "run" or application files with SME that come with the distro that can be ran?

No.

Code: [Select]
ls /bin /usr/bin /sbin /usr/sbin /sbin/e-smith

will show you just how many choices you have - many of them dangerous.


Offline byte

  • *
  • 2,183
  • +2/-0
Re: Reading DHCP assignments in SME
« Reply #2 on: November 23, 2007, 07:16:16 PM »
I think, though, that somebody developed a contrib which can display the leases via the server-manager.

They did but it was never developed for SME 7.x
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

Offline morrislex

  • *
  • 7
  • +0/-0
Re: Reading DHCP assignments in SME
« Reply #3 on: November 23, 2007, 07:18:06 PM »
      Found an old post for a script that works



         how to track the work of the DHCP Server?
      « Reply #6 on: March 03, 2007, 02:50:48 PM »    Quote

      ________________________________________
      Option 1:
      Open a command shell using putty or ssh
      Copy and paste the script from my earlier post

      Option 2:
      open a command shell using putty or ssh
      create the script using
      pico -w ~/dhcpactiv.sh
      copy and paste the contents of the script from here to your command shell
      press ^X to close pico, saving your file as you exit
      run using sh ~/dhcpactiv.sh
    Here's another version of the script that lists
    Active leases from /var/lib/dhcp/dhcpd.leases
    Reservations that exist in /etc/dhcpd.conf
    Recently accessed network hosts using
    arp -a
(Note: This version must be saved as a script using "Option 2" or the output is unreadable...)
Code:
#!/bin/sh
#
# dhcpactiv.sh
#
# v.004
# - rewritten again to pull data from dhcpd files according to labels instead of position
#
# v.003
# - add code to remove tstp information from dpcpd.leases
#
# v.002
# - rewritten to use awk more for parsing
# - added "GMT" indicator to Expiration col head
#
echo "Source        Host       MAC Address       IP Address      Expiration (GMT)"
echo "============= ========== ================= =============== ================"
#
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," " }' /var/lib/dhcp/dhcpd.leases \
  | grep active \
  | sed -e s/'[{};" ]'/\ /g  \
  | awk '{ printf "%-13s %-10s %-17s %-15s %-10s %-5s\n", "dhcpd.leases", $6, $5, $1, $2, $3 }'

#
# Now do the same for /etc/dhcpd.conf
#
 awk ' { out = ""}
       { $1=="host"||$1=="fixed-address" ? out=" " $2 : out=out } \
       { $1=="hardware" ? out= " " $3: out=out } \
       { $1=="}"? out="\n": out=out } \
       { printf out," " }' /etc/dhcpd.conf \
  | grep : \
  | sed -e  s/'[{};\" ]'/\ /g -e  s/\.`config get DomainName`// \
  | awk  '{ printf "%-13s %-10s %-17s %-15s %-15s \n", "dhcpd.conf", $1, $2, $3, "reservation"}'
#
# Finally, grab the current arp table
#
arp -a \
  |  sed -e s/\\..*\(/\ / -e s/\)// \
  |  awk '{ printf "%-13s %-10s %-17s %-15s %-15s \n", "arp", $1, $4, $2, "n/a"}'