get DHCP information

get DHCP information

Post by Bit Twiste » Fri, 13 Jun 2003 05:30:47




> I'm attempting to duplicate the "ipconfig /all" functionality in windows.
> Specifically I was looking for DHCP lease start and end information. Here's
> what I found out.

> Lease time, client and dhcp server addresses, etc. can be found in
> /var/lib/dhcp/dhclient.leases ascii DB. And of course you can get hostname
> info from other places, e.g. 'hostname'.

> Is there a cmd that pulls it all together and displays it for the user?

You could create a script to cat each file.

Or you could create a script which reads the values and prints them
however you like.

http://www.tldp.org/LDP/abs/html/index.html   for script info.

Here is my code to dump lease information from  dhcpcd
#******************************************************************************
#*
#*      lease - display lease infomation created by dhcpcd deamon
#*
#*      Information comes from /etc/dhcpc/dhcpcd-ethX.info
#*
#*      Change _nic=eth1 to _nic=eth0, if that is where the lease comes from.
#*      Change _loc=To location of dhcpcd-ethX.info
#*
#*      Do a     locate dhcpcd- | grep info    to find dhcpcd-ethX.info
#*      You may have to do a     updatedb      to create the file location db.
#*
#*      chmod +x lease        after you save this to disk
#*
#******************************************************************************

_nic=eth1                       # nic that the lease is from
_loc=/etc/dhcpc                 # location of dhcpcd-ethX.info

if [ ! -s ${_loc}/dhcpcd-${_nic}.info ] ; then
  echo ${_loc}/dhcpcd-${_nic}.info does not exist
  exit 1
fi

. ${_loc}/dhcpcd-${_nic}.info   # load dhcpcd-ethX.info vars

set `date`
_yy=$6                          # save this year

set `date -r ${_loc}/dhcpcd-${_nic}.info`

_obt="$1 $2 $3 $4 $5"   # save obtained date
_day=$3
_time=$4

        case $2 in
          Jan) _mo=1 ;;
          Feb) _mo=2 ;;
          Mar) _mo=3 ;;
          Apr) _mo=4 ;;
          May) _mo=5 ;;
          Jun) _mo=6 ;;
          Jul) _mo=7 ;;
          Aug) _mo=8 ;;
          Sep) _mo=9 ;;
          Oct) _mo=10 ;;
          Nov) _mo=11 ;;
          Dec) _mo=12 ;;
        esac

_lease="${_yy}-${_mo}-$_day ${_time}Z +$LEASETIME seconds"
_new="${_yy}-${_mo}-$_day ${_time}Z +$RENEWALTIME seconds"
_reb="${_yy}-${_mo}-$_day ${_time}Z +$REBINDTIME seconds"

echo " "
echo ${_loc}/dhcpcd-${_nic}.info
echo " "
echo "Obtained  `date -d "$_obt"` "
echo "Renewal           `date -d "$_new"` "
echo "Expires           `date -d "$_lease"` "
echo "Rebind            `date -d "$_reb"` "
echo " "
echo "DNS $DNS "
echo " "

#*************************** end lease **************************************

 
 
 

1. Getting DNS information from DHCP

I have a 3com90x (100 megabit) ethernet card.

I installed Red Hat 6.0 from a FTP site (metalab).  The install
worked fine.  It got an IP address from DHCP and got the
nameserver information.  For the ftp site I typed in ftp.metalab.unc.edu.

I chose the custom install and installed almost everything off of
the main list, except for some of the image manipulation stuff like
the TeX stuff.

After the install completed and I rebooted I logged in as root, and
tried to ping a site (ftp.metalab.unc.edu) and it said it couldn't find
it.  I looked at ifconfig, and eth0 had gotten an ip address and
appeared to be working, as I could ping addresses (no name
server required).

Did I miss something in the install?  Why am I not retrieving name
server information from the DHCP request, or is there something
additional I need?  I noticed in the install there were 2 messages.
 One said it was making a DHCP request, the other said it was
looking up name server and domain information.

The really odd thing is that the very first time I installed Red Hat 6.0
(from ftp), when the system came up, it had the nameserver information
(from DHCP or wherever), but I don't remember doing anything different.

Any help anyone could provide for getting name server information
dynamically would be appreciated.

2. Probs with 1.3.X(41) and std serial

3. getting the network interface information and default gateway information ??

4. any Solaris ELF documents?

5. 3com 905b gets Ip address by using DHCP from NT DHCP server

6. Email can not be sent even when DNS works

7. DHCP Problem, Getting a Reply but its not getting configured? ? ? ? ??

8. Serial port expansion board recommendation?

9. DHCP Optional Information.

10. DHCP information

11. Seeking only some information by DHCP

12. RH 5.1 flawless ftp-dhcp install; dhcp config retained; dhcp fails @ boot

13. Converting DHCP information