[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Changing IP addresses with dhclient



Hi Tim,

thank you for your reply. The "Last write time" from the filesystem superblock 
does only refer to writes to the superblock not the entire filesystem:

root@bokocube:~# dumpe2fs -h /dev/mmcblk0p2|grep Last
dumpe2fs 1.42.10 (18-May-2014)
Last mounted on:          /
Last mount time:          Thu Jan  1 01:00:04 1970
Last write time:          Thu Jan  1 01:00:04 1970
Last checked:             Sat Jun 14 20:19:23 2014
root@bokocube:~#

Thus I followed the idea to use the timestamp of syslog:

rd@bokocube:~$ cat /etc/init.d/clockemu
#!/bin/sh
### BEGIN INIT INFO
# Provides:          clockemu
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Should-Start:      $portmap
# Should-Stop:       $portmap
# X-Start-Before:    syslog
# X-Stop-After:      syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# X-Interactive:     true
# Short-Description: emulates the RTC by setting the clock to the 
/var/log/syslog write time as early as possible
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh

set -vx

do_start() {
        date "+%D %T" -s "`date "+%D %T" -r /var/log/syslog`"
}

case "$1" in
    start)
        do_start
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
rd@bokocube:~$ 

This looks much better now:

root@bokocube:~# grep "bound to" /var/log/syslog
Jun 28 15:46:36 bokocube dhclient: bound to 192.168.178.87 -- renewal in 
395611 seconds.
Jun 28 15:46:38 bokocube dhclient: bound to 192.168.178.87 -- renewal in 
388322 seconds.
Jun 28 15:46:38 bokocube ifup[239]: bound to 192.168.178.87 -- renewal in 
388322 seconds.
Jun 28 16:04:08 bokocube dhclient: bound to 192.168.178.87 -- renewal in 
403727 seconds.
Jun 28 16:04:10 bokocube dhclient: bound to 192.168.178.87 -- renewal in 
388322 seconds.
Jun 28 16:04:10 bokocube ifup[247]: bound to 192.168.178.87 -- renewal in 
388322 seconds.
Jun 28 16:16:20 bokocube dhclient: bound to 192.168.178.87 -- renewal in 
399151 seconds.
Jun 28 16:16:22 bokocube dhclient: bound to 192.168.178.87 -- renewal in 
368472 seconds.
Jun 28 16:16:22 bokocube ifup[238]: bound to 192.168.178.87 -- renewal in 
368472 seconds.
root@bokocube:~# 

i.e. four boots in a row got consistently the *.87 address.

It becomes interesting, what happens when the lease expires in 8 days time.

Thanks,
Rainer


On Saturday 28 June 2014 14:01:27 Tim Small wrote:
> I think you'll need to use wireshark to figure out what's different (if
> anything) about the two sets of dhcp requests.
> 
> You might want to run wireshark on another box with two NICs bridged
> (cubox into one, router into the other) to ensure you see unicast as
> well as broadcast traffic.
> 
> Alternatively, you could start tcpdump on the cubox early in the boot
> process to create a packet trace file, and load that into wireshark
> later for analysis.
> 
> Possibly the changing local time is making the local cubox dhclient not
> request a lease renewal, but to request?  You could hack around this by
> setting the time prior to dhcp, using the timestamp of something on
> local storage - like a log file (or the "Last write time" from the
> filesystem superblock).  The time will still be wrong, but at least the
> machine won't have seem like it time-travelled backwards.
> 
> If you can't find anything changing between the two requests, then it's
> probably down to the router policy.
> 
> Tim.
> 
> On 28/06/14 13:42, Rainer Dorsch wrote:
> > Hi Ian,
> > 
> > On Saturday 28 June 2014 10:28:33 Ian Campbell wrote:
> >> On Sat, 2014-06-28 at 10:23 +0200, Rainer Dorsch wrote:
> >>> The real question is why does the dhclient on the cubox-i
> >>> http://cubox-i.com/ get another IP address when it asks again?
> >> 
> >> Is it possible that it is booting with some hardcoded default MAC
> >> address which gets set to the proper one during boot, before the clock
> >> change forces a second DHCP request?
> > 
> > I thought about that, but the weired thing is that sometimes it has *.87
> > after booting and changes to *.88 and sometimes the other way round. Here
> > are two of these examples
> > 
> > rd@bokocube:/var/log$ grep "bound to" syslog
> > Jan  1 01:00:10 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 342127 seconds.
> > Jan  1 01:00:12 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 369324 seconds.
> > Jan  1 01:00:12 bokocube ifup[238]: bound to 192.168.178.87 -- renewal in
> > 369324 seconds.
> > Jun 28 11:37:08 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 371052 seconds.
> > Jun 28 11:37:08 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 392786 seconds.
> > Jan  1 01:00:09 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 379228 seconds.
> > Jan  1 01:00:12 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 369324 seconds.
> > Jan  1 01:00:12 bokocube ifup[244]: bound to 192.168.178.88 -- renewal in
> > 369324 seconds.
> > Jan  1 01:00:09 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 361711 seconds.
> > Jan  1 01:00:10 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 423282 seconds.
> > Jan  1 01:00:10 bokocube ifup[238]: bound to 192.168.178.88 -- renewal in
> > 423282 seconds.
> > Jun 28 14:02:58 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 370838 seconds.
> > Jun 28 14:02:58 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 365945 seconds.
> > rd@bokocube:/var/log$
> > 
> > Also this is independent of setting a dhcp-client-identifier in
> > dhclient.conf or not.
> > 
> >> Perhaps the DHCP server logs can give you a clue why it decided to give
> >> a new IP address instead of reusing the existing lease?
> > 
> > Unfortunately, the server side is a router, I do not see log entries from
> > dhcp requests. The only weired observation on the router is that one
> > entry (either *.87 or *.88) has an empty MAC address. But not even that
> > is fix, also the IP with the empty MAC address "oscillates".
> > 
> > Here is the complete client log for reference:
> > 
> > rd@bokocube:/var/log$ grep dhclient syslog
> > Jan  1 01:00:08 bokocube NetworkManager[341]: <info> dhclient started with
> > pid 427
> > Jan  1 01:00:08 bokocube dhclient: Internet Systems Consortium DHCP Client
> > 4.3.0
> > Jan  1 01:00:08 bokocube dhclient: Copyright 2004-2014 Internet Systems
> > Consortium.
> > Jan  1 01:00:08 bokocube dhclient: All rights reserved.
> > Jan  1 01:00:08 bokocube dhclient: For info, please visit
> > https://www.isc.org/software/dhcp/
> > Jan  1 01:00:08 bokocube dhclient:
> > Jan  1 01:00:08 bokocube dhclient: Listening on LPF/eth0/d0:63:b4:00:32:5c
> > Jan  1 01:00:08 bokocube dhclient: Sending on   LPF/eth0/d0:63:b4:00:32:5c
> > Jan  1 01:00:08 bokocube dhclient: Sending on   Socket/fallback
> > Jan  1 01:00:08 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 8
> > Jan  1 01:00:09 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jan  1 01:00:09 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jan  1 01:00:10 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jan  1 01:00:10 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 342127 seconds.
> > Jan  1 01:00:12 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jan  1 01:00:12 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jan  1 01:00:12 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 369324 seconds.
> > Jun 28 11:37:07 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 5
> > Jun 28 11:37:07 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 8
> > Jun 28 11:37:08 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jun 28 11:37:08 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jun 28 11:37:08 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jun 28 11:37:08 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 371052 seconds.
> > Jun 28 11:37:08 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jun 28 11:37:08 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jun 28 11:37:08 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jun 28 11:37:08 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 392786 seconds.
> > Jan  1 01:00:08 bokocube NetworkManager[343]: <info> dhclient started with
> > pid 431
> > Jan  1 01:00:08 bokocube dhclient: Internet Systems Consortium DHCP Client
> > 4.3.0
> > Jan  1 01:00:08 bokocube dhclient: Copyright 2004-2014 Internet Systems
> > Consortium.
> > Jan  1 01:00:08 bokocube dhclient: All rights reserved.
> > Jan  1 01:00:08 bokocube dhclient: For info, please visit
> > https://www.isc.org/software/dhcp/
> > Jan  1 01:00:08 bokocube dhclient:
> > Jan  1 01:00:08 bokocube dhclient: Listening on LPF/eth0/d0:63:b4:00:32:5c
> > Jan  1 01:00:08 bokocube dhclient: Sending on   LPF/eth0/d0:63:b4:00:32:5c
> > Jan  1 01:00:08 bokocube dhclient: Sending on   Socket/fallback
> > Jan  1 01:00:08 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 7
> > Jan  1 01:00:09 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jan  1 01:00:09 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jan  1 01:00:09 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jan  1 01:00:09 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 379228 seconds.
> > Jan  1 01:00:12 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jan  1 01:00:12 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jan  1 01:00:12 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 369324 seconds.
> > Jan  1 01:00:08 bokocube NetworkManager[344]: <info> dhclient started with
> > pid 432
> > Jan  1 01:00:08 bokocube dhclient: Internet Systems Consortium DHCP Client
> > 4.3.0
> > Jan  1 01:00:08 bokocube dhclient: Copyright 2004-2014 Internet Systems
> > Consortium.
> > Jan  1 01:00:08 bokocube dhclient: All rights reserved.
> > Jan  1 01:00:08 bokocube dhclient: For info, please visit
> > https://www.isc.org/software/dhcp/
> > Jan  1 01:00:08 bokocube dhclient:
> > Jan  1 01:00:08 bokocube dhclient: Listening on LPF/eth0/d0:63:b4:00:32:5c
> > Jan  1 01:00:08 bokocube dhclient: Sending on   LPF/eth0/d0:63:b4:00:32:5c
> > Jan  1 01:00:08 bokocube dhclient: Sending on   Socket/fallback
> > Jan  1 01:00:08 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 5
> > Jan  1 01:00:09 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jan  1 01:00:09 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jan  1 01:00:09 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jan  1 01:00:09 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 361711 seconds.
> > Jan  1 01:00:10 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jan  1 01:00:10 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jan  1 01:00:10 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 423282 seconds.
> > Jun 28 14:02:57 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 5
> > Jun 28 14:02:57 bokocube dhclient: DHCPDISCOVER on eth0 to 255.255.255.255
> > port 67 interval 5
> > Jun 28 14:02:58 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jun 28 14:02:58 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jun 28 14:02:58 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jun 28 14:02:58 bokocube dhclient: bound to 192.168.178.88 -- renewal in
> > 370838 seconds.
> > Jun 28 14:02:58 bokocube dhclient: DHCPREQUEST on eth0 to 255.255.255.255
> > port 67
> > Jun 28 14:02:58 bokocube dhclient: DHCPOFFER from 192.168.178.1
> > Jun 28 14:02:58 bokocube dhclient: DHCPACK from 192.168.178.1
> > Jun 28 14:02:58 bokocube dhclient: bound to 192.168.178.87 -- renewal in
> > 365945 seconds.
> > rd@bokocube:/var/log$
> > 
> > Thanks,
> > Rainer

-- 
Rainer Dorsch
http://bokomoko.de/


Reply to: