Evert Carton wrote:
> Hi all,
>
> 1) Is there an easy scriptable way to find out whether there is a
> DHCP-server on the network you're connecting to ?
> Also:
> 2) (and I know this is probably a bad idea)
> Is there an easy scriptable way to find out about the IP-network
> you're connecting to ? And more: to find available IP-adresses, ie,
> IP-addresses that are not in use ?
> The second problem would be tricky I guess, since if you want to use
> broadcast to find out, it does somewhat imply that you have an
> IP-addresses assigned to your card already, in the IP-network you're
> connecting to. It would therefore more be a broadcast on MAC-level,
> and ask all the cards you've found for their IP-address. Dunno if this
> is possible. I do know (or should I say: I do presume) that IP-usually
> works by issuing an ARP "whohas x.x.x.x"-broadcast request, upon which
> communication with that discovered card does work on MAC-level. Hence
> the use of ARP-tables. I don't know whether issuing a request for an
> IP-address to a given MAC-address, the reverse query. I would need to
> discover before the IP-addresses is assigned to my card. I would like
> to use answers to the above to make decisions about configuration for
> my card. And I know, I know, this would somewhat imply
> "stealing" an IP-address that might not be available not be available
> 10 minutes from now. 3) Do I make any sense ? ;-)
>
> Regards,
> Evert
"3) Do I make any sense?"
No.
What are your trying to achieve that the standard dhcp client that was
probably installed in your system by default will not achieve?
Why do you want to find out all of the available ip addresses? You only
need to use the one that the dhcp server daemon assigns to you and you
dhcp client daemon will do that for you.
You don't need to have an ip address to get an ip address. Your machine
starts out with an ip address of 0.0.0.0 and your dhcp client daemon
takes care of asking the dhep server daemon to give it an ip address
which it then uses to communicate with the net. You broadcast a
request and a dhcp server daemon broadcasts an offer. Neither need know
the ip address of the other and in fact the client doesn't actually
have one.
It you accept the offer the server assigns an ip address on a fixed time
lease and specifies a netmask and the addresses of a couple of dns
servers and secifies a gateway address and your dhcp client daemon will
then configure your network connection to conform, all untouched by
human hands.
Once the two dhcp daemons have done their job, the system will then
bahave the same as any fixed ip system until you shut down or until the
time comes to renew the lease, at which time the two will again
communicate with each other for that purpose.
Clive
Modern
|