[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dhcp-client
Subject:    RE: dhclient dependencies
From:       "Jordi Haarman" <J.Haarman () cable ! a2000 ! nl>
Date:       2000-01-24 16:51:13
[Download RAW message or body]

   *** From dhcp-client -- To unsubscribe, see the end of this message. ***

ok the "dhclient ethX > file 2>&1" worked! thx.

You rule! I'm getting a ip from the server now but still a lot of error
messages. Maybe it is easy solved:

Internet Software Consortium DHCP Client 2.0
Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.
All rights reserved.

Please contribute if you find this software useful.
For info, please visit http://www.isc.org/dhcp-contrib.html

/etc/dhclient-script: uname: command not found
/etc/dhclient-script: expr: command not found
/etc/dhclient-script: sed: command not found
/etc/dhclient-script: sed: command not found
/etc/dhclient-script: [: -lt: unary operator expected
/etc/dhclient-script: [: -eq: unary operator expected
Listening on LPF/eth0/00:10:5a:48:10:14
Sending on   LPF/eth0/00:10:5a:48:10:14
Sending on   Socket/fallback/fallback-net
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.100.200
/etc/dhclient-script: uname: command not found
/etc/dhclient-script: expr: command not found
/etc/dhclient-script: sed: command not found
/etc/dhclient-script: sed: command not found
/etc/dhclient-script: hostname: command not found
/etc/dhclient-script: [: -lt: unary operator expected
/etc/dhclient-script: [: -eq: unary operator expected
SIOCADDRT: File exists
bound to 192.168.100.157 -- renewal in 18000 seconds.


> -----Original Message-----
> From: Ted Lemon [mailto:mellon@isc.org]
> Sent: maandag 24 januari 2000 17:16
> To: Jordi Haarman
> Cc: Dhcp-Client
> Subject: Re: dhclient dependencies
>
>
>
> > Is the scripting easy done? (I'm not that good in linux)
>
> Sigh.   Why are you trying to do magic, then?   You will probably
> *get* good in the process!   :')
>
> > How can I get the dhclient output to a file? dhclient ethX >
> file doesn't
> > seem to work.
>
> Try "dhclient ethX >& file", or if you get an error message when you
> do that, try "dhclient ethX > file 2>&1".  Unix has two output
> descriptors - stdout (1) and stderr (2).  Dhclient logs most of its
> output to stderr, rather than stdout, which is why "dhclient ethX
> >file" doesn't work - ">" redirects only stdout.  In the bourne shell
> (and probably bash) you can redirect stderr to stdout with "2>&1".
> In the C shell, you can redirect stdout and stderr to a file with
> ">&".
>
> To fix the script, you need to understand Bourne shell programming.
> It sounds like you don't, so I've included a modified script below
> that may work for you.   I haven't tested it, so I make no
> promises...
>
> I'd suggest getting a book on bourne shell programming or bash
> programming if you want to do much with Linux - you won't regret it.
> O'Reilly probably has what you need.
>
> 			       _MelloN_
>
> #!/bin/sh
> # dhclient-script for Linux. Dan Halbert, March, 1997.
> # Updated for Linux 2.[12] by Brian J. Murrell, January 1999.
> # No guarantees about this. I'm a novice at the details of Linux
> # networking.
>
> # Notes:
>
> # 0. This script is based on the netbsd script supplied with dhcp-970306.
>
> # 1. ifconfig down apparently deletes all relevant routes and flushes
> # the arp cache, so this doesn't need to be done explicitly.
>
> # 2. The alias address handling here has not been tested AT ALL.
> # I'm just going by the doc of modern Linux ip aliasing, which uses
> # notations like eth0:0, eth0:1, for each alias.
>
> # 3. I have to calculate the network address, and calculate the broadcast
> # address if it is not supplied. This might be much more easily done
> # by the dhclient C code, and passed on.
>
> # 4. TIMEOUT not tested. ping has a flag I don't know, and I'm suspicious
> # of the $1 in its args.
>
> # Invoke the local dhcp client enter hooks, if they exist.
> if [ -x /etc/dhclient-enter-hooks ]; then
>   exit_status=0
>   . /etc/dhclient-enter-hooks
>   # allow the local script to abort processing of this state
>   # local script must set exit_status variable to nonzero.
>   if [ $exit_status -ne 0 ]; then
>     exit $exit_status
>   fi
> fi
>
> release=`uname -r`
> release=`expr $release : '\(.*\)\..*'`
> relmajor=`echo $release |sed -e 's/^\([^\.]*\)\..*$/\1/'`
> relminor=`echo $release |sed -e 's/^.*\.\([^\.]*\)$/\1/'`
>
> if [ x$new_broadcast_address != x ]; then
>   new_broadcast_arg="broadcast $new_broadcast_address"
> fi
> if [ x$old_broadcast_address != x ]; then
>   old_broadcast_arg="broadcast $old_broadcast_address"
> fi
> if [ x$new_subnet_mask != x ]; then
>   new_subnet_arg="netmask $new_subnet_mask"
> fi
> if [ x$old_subnet_mask != x ]; then
>   old_subnet_arg="netmask $old_subnet_mask"
> fi
> if [ x$alias_subnet_mask != x ]; then
>   alias_subnet_arg="netmask $alias_subnet_mask"
> fi
>
> if [ x$reason = xMEDIUM ]; then
>   # Linux doesn't do mediums (ok, ok, media).
>   exit_status=0
>   if [ -x /etc/dhclient-exit-hooks ]; then
>     . /etc/dhclient-exit-hooks
>   fi
> # probably should do something with exit status of the local script
>   exit $exit_status
> fi
>
> if [ x$reason = xPREINIT ]; then
>   if [ x$alias_ip_address != x ]; then
>     # Bring down alias interface. Its routes will disappear too.
>     ifconfig $interface:0- inet 0
>   fi
>   if [ $relmajor -lt 2 ] || ( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] )
>    then
>     ifconfig $interface inet 0.0.0.0 netmask 0.0.0.0 \
> 		broadcast 255.255.255.255 up
>     # Add route to make broadcast work. Do not omit netmask.
>     route add default dev $interface netmask 0.0.0.0
>   else
>     ifconfig $interface up
>   fi
>
>   # We need to give the kernel some time to get the interface up.
>   sleep 1
>
>   exit_status=0
>   if [ -x /etc/dhclient-exit-hooks ]; then
>     . /etc/dhclient-exit-hooks
>   fi
> # probably should do something with exit status of the local script
>   exit $exit_status
> fi
>
> if [ x$reason = xARPCHECK ] || [ x$reason = xARPSEND ]; then
>   exit_status=0
>   if [ -x /etc/dhclient-exit-hooks ]; then
>     . /etc/dhclient-exit-hooks
>   fi
> # probably should do something with exit status of the local script
>   exit $exit_status
> fi
>
> if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \
>    [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then
>   current_hostname=`hostname`
>   if [ x$current_hostname = x ] || \
>      [ x$current_hostname = x$old_host_name ]; then
>     if [ x$new_host_name != x$old_host_name ]; then
>       hostname $new_host_name
>     fi
>   fi
>   if [ x$old_ip_address != x ] && [ x$alias_ip_address != x ] && \
> 		[ x$alias_ip_address != x$old_ip_address ]; then
>     # Possible new alias. Remove old alias.
>     ifconfig $interface:0- inet 0
>   fi
>   if [ x$old_ip_address != x ] && [ x$old_ip_address !=
> x$new_ip_address ]; then
>     # IP address changed. Bringing down the interface will delete
> all routes,
>     # and clear the ARP cache.
>     ifconfig $interface inet down
>
>   fi
>   if [ x$old_ip_address = x ] || [ x$old_ip_address !=
> x$new_ip_address ] || \
>      [ x$reason = xBOUND ] || [ x$reason = xREBOOT ]; then
>
>     ifconfig $interface inet $new_ip_address $new_subnet_arg \
> 							$new_broadcast_arg
>     # Add a network route to the computed network address.
>     if [ $relmajor -lt 2 ] || \
> 		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
>       route add -net $new_network_number $new_subnet_arg dev $interface
>     fi
>     for router in $new_routers; do
>       route add default gw $router
>     done
>   fi
>   if [ x$new_ip_address != x$alias_ip_address ] &&

> x$alias_ip_address != x ];
>    then
>     ifconfig $interface:0- inet 0
>     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
>     route add -host $alias_ip_address $interface:0
>   fi
>   echo search $new_domain_name >/etc/resolv.conf
>   for nameserver in $new_domain_name_servers; do
>     echo nameserver $nameserver >>/etc/resolv.conf
>   done
>   exit_status=0
>   if [ -x /etc/dhclient-exit-hooks ]; then
>     . /etc/dhclient-exit-hooks
>   fi
> # probably should do something with exit status of the local script
>   exit $exit_status
> fi
>
> if [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ]; then
>   if [ x$alias_ip_address != x ]; then
>     # Turn off alias interface.
>     ifconfig $interface:0- inet 0
>   fi
>   if [ x$old_ip_address != x ]; then
>     # Shut down interface, which will delete routes and clear arp cache.
>     ifconfig $interface inet down
>   fi
>   if [ x$alias_ip_address != x ]; then
>     ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
>     route add -host $alias_ip_address $interface:0
>   fi
>   exit_status=0
>   if [ -x /etc/dhclient-exit-hooks ]; then
>     . /etc/dhclient-exit-hooks
>   fi
> # probably should do something with exit status of the local script
>   exit $exit_status
> fi
>
> if [ x$reason = xTIMEOUT ]; then
>   if [ x$alias_ip_address != x ]; then
>     ifconfig $interface:0- inet 0
>   fi
>   ifconfig $interface inet $new_ip_address $new_subnet_arg \
> 					$new_broadcast_arg
>   set $new_routers
>   ############## what is -w in ping?
>   if ping -q -c 1 $1; then
>     if [ x$new_ip_address != x$alias_ip_address ] && \
> 			[ x$alias_ip_address != x ]; then
>       ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
>       route add -host $alias_ip_address dev $interface:0
>     fi
>     if [ $relmajor -lt 2 ] || \
> 		( [ $relmajor -eq 2 ] && [ $relminor -eq 0 ] ); then
>       route add -net $new_network_number
>     fi
>     for router in $new_routers; do
>       route add default gw $router
>     done
>     echo search $new_domain_name >/etc/resolv.conf.std
>     for nameserver in $new_domain_name_servers; do
>       echo nameserver $nameserver >>/etc/resolv.conf.std
>     done
>     if [ -f /etc/resolv.conf ]; then
>       rm -f /etc/resolv.conf
>       ln /etc/resolv.conf.std /etc/resolv.conf
>     fi
>     exit_status=0
>     if [ -x /etc/dhclient-exit-hooks ]; then
>       . /etc/dhclient-exit-hooks
>     fi
> # probably should do something with exit status of the local script
>     exit $exit_status
>   fi
>   ifconfig $interface inet down
>   exit_status=1
>   if [ -x /etc/dhclient-exit-hooks ]; then
>     . /etc/dhclient-exit-hooks
>   fi
> # probably should do something with exit status of the local script
>   exit $exit_status
> fi
>
> exit_status=0
> if [ -x /etc/dhclient-exit-hooks ]; then
>   . /etc/dhclient-exit-hooks
> fi
> # probably should do something with exit status of the local script
> exit $exit_status
>
>


-----------------------------------------------------------------------
To unsubscribe from this list, visit http://www.isc.org/dhcp-lists.html
or send mail to dhcp-client-request@isc.org with the subject line of
'unsubscribe'.
-----------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic