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

Re: Questions regarding dynamic IPs and dhcpcd



Colin R. Telmer:
> The dynamic-hacks mini-HOWTO really only deals with ppp. pppd outputs the
> new ip address in $4. Is there anything similar to this for dhcpcd? I
> can't find anything in the man page and I assume that I will need to
> extract this from /etc/dhcpc/hostinfo-eth0.
> 
> Given this, after some experimentation, when I boot the remote machine (I
> am in Burlington at the moment) it takes dhcpcd approximately 3 minutes to
> configure the network and at that point /etc/dhcpc/hostinfo-eth0 is
> updated and /var/run/dhcpcd-cache.eth0 is created. So I have to wait until
> this happens to extract the ip address from /etc/dhcpc/hostinfo-eth0. 
> 
> So what I want to do is write a script that waits until
> /var/run/dhcpcd.cache-eth0 is created and then mails me
> /etc/dhcpc/hostinfo-eth0. The waiting part is the part I do not know how
> to do unless I just use an infinite loop (with perhaps a 10 minute limit)
> that continously checks for /var/run/dhcpcd.cache-eth0. Is there a better
> way to do this?

Yes, there is. My sister's linux box used to be set up the same (it isn't
any more, and I no longer use dhcpcd, so this explianation might be 
inaccurate.)

Dcpcd lets you run an arbitrary program whenever it reconfigures the IP
address. Note that it's possible that the computer boots, is assigned one
IP address, and an hour later the IP addres is changed, which is why dpcpcd
keeps running as a daemon after boot. So just checking the
/var/run/dhcpcd.cache-eth0 file once isn't really good enough, anyway. 

Take a look at the dhcpcd man page, where it says:

       -c filename
              Specifies the command file which  is  invoked  when
              dhcpcd successfully gets an IP address.

So you make a shell script that mails the info to your other computer, and
then edit the /etc/init.d/dhcpc file that starts dhcpcd and change this line:

    start-stop-daemon --start --quiet --exec $DAEMON -- $IFACE

to:

    start-stop-daemon --start --quiet --exec $DAEMON -- $IFACE -c scriptname

-- 
see shy jo, dhcpcd maintainer


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: