Reputation: 703
Working on a shell script that takes a machine name as an argument and then determines if the host is on the local network (same network as the machine that ran the script).
How can I get the IP address from the machine name? Once I get that I should be able to compare that IP with the local one to see if they're on the same subnet.
Upvotes: 1
Views: 513
Reputation: 20980
What do you mean by local network
? subnet or (windows) domain or within LAN?
You may also have a look at traceroute
utility.
Upvotes: 0
Reputation: 796
You can use nslookup
(http://linux.die.net/man/1/nslookup), dig
(http://linux.die.net/man/1/dig) or host
(http://linux.die.net/man/1/host) command-line utilities.
For example, here is the result of running host
for getting A-records for stackoverflow.com from DNS server:
$ host -tA stackoverflow.com
stackoverflow.com has address 69.59.197.21
Upvotes: 2