Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Ubuntu Hardy Desktop, Solaris 10, Workstation 2008 x64
Posts: 75
Rep:
Lookup hostname from IP address
Hi guys
I'm writing a script to parse the ip table from my router but I'm up against a brick wall of how to easily convert from an ip address to a hostname.
whois creates alot of output and is not standardised really, I'm just simply looking to get from xxx.xx.xx.xx to computer.domain.tld
Hi guys
I'm writing a script to parse the ip table from my router but I'm up against a brick wall of how to easily convert from an ip address to a hostname.
whois creates alot of output and is not standardised really, I'm just simply looking to get from xxx.xx.xx.xx to computer.domain.tld
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660
Rep:
Code:
$ dig +short -x <ip address>
works too. Don't use nslookup for anything, it's deprecated and due to be replaced. Learn to use dig instead.
PS Be aware that you'll get an empty string if there is no PTR record for the IP address, so you script has to know that an empty response from dig means that there's no PTR for the IP.
Distribution: Ubuntu Hardy Desktop, Solaris 10, Workstation 2008 x64
Posts: 75
Original Poster
Rep:
Cheers, using dig, works great. Wish more people had stuff like this documented online, i spent about 30 minutes googling "lookup hostname from ip unix" "reverse dns unix ip hostname".... and so the list of polymorphic combinations went on....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.