[Beowulf] How to judge whether an ip address is local or not
Robert G. Brown
rgb at phy.duke.edu
Mon Aug 15 12:50:24 EDT 2005
On Mon, 15 Aug 2005, Zhang Hui wrote:
> I need to judge whether an ip address is local in kernel state.
> Can anyone help me?
> Great appreciation to any apply.
What do you mean by "local"? There are all sorts of ways to learn all
sorts of pieces of information about ip addresses and network
connectivity. Some of them (e.g. ICMP) require root privileges and are
typically accessible only by root or with an suid root application.
If you mean "I need to find out what IP addresses a given machine has
from a shell on that machine" there is the /sbin/ifconfig command as
well as information you can optain directly from e.g.
If you mean "I need to find out what IP addresses are on the "local"
network attached to a given NIC on a given machine" -- that's a bit
different and probably needs some qualification. For example, local in
that sense might be interpreted as on the same IP subnet, in the same IP
broadcast space, or within a flat ethernet broadcast space. Obviously
there has to be some sort of boundary defined, as otherwise most network
interfaces CAN access the entire internet, right?
Many of these will involve scanning the LAN for addresses, and in all
probability the "nmap" tool will do what you need. nmap uses a scan and
icmp ping (or a tcp-based cheat on icmp) to do part of its work here and
generally requires root privileges or that the scanned hosts respond to
connection attempts on certain TCP ports. It requires some sort of
boundaries because if you do an unrestricted scan outside of your LAN it
will be interpreted by many sysadmins as a cracking attempt and you
might find yourself being hung up by your thumbs or something.
Robert G. Brown http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567 Fax: 919-660-2525 email:rgb at phy.duke.edu
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf
More information about the Beowulf