At 01:39 PM 4/28/00 -0700, Dan Browning wrote:
>In a shell script, how do I assign a varialbe the current dynamic ip address
>for a given interface? What about current default gateway?
I saw that Greg already answered the question you asked. I thought I'd
supplement his response by answering one you didn't ask, but might have
asked had you known to.
If the dynamic IP address and gateway are being reassigned in a DHCP lease,
the standard Linux DHCP client (dhcpcd) has the provision to execute a
script or program every time it gets a new lease for an interface. It also
stores the information it gets in the lease in a fairly readable format. The
releavnt filenames (on my Debian system, anyway) are:
/etc/dhcpc/dhcpcd-eth0.exe will execute this one
/etc/dhcpc/dhcpcd-eth0.info holds the lease info
You replace the "eth0" part with the actual interface, of course.
If the dynamic IP address and gateway are being reassigned in a PPP
negotiation,
you might be able to do something similar using the /etc/ppp/ip-up script
described in the pppd man page (and /etc/ppp/ppp-down for when the
connection ends). It can access the local and remote IP addresses of the PPP
link as environment variables.
These approaches have the advantage that the act of getting addresses
triggers the appropriate script, so you don't have to poll the interface and
routing table periodically. Depending on why you need the interface and
gateway addresses, this may be a simpler approach for you.
------------------------------------"Never tell me the odds!"---
Ray Olszewski -- Han Solo
Palo Alto, CA [EMAIL PROTECTED]
----------------------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs