#!/usr/bin/perl ########################################### # dns - resolve hostnames to IPs # Mike Schilli, 2004 (m@perlmeister.com) ########################################### use warnings; use strict; our $CVSVERSION = '$Revision: 1.3 $'; use CGI qw(header); use CGI qw(fatalsToBrowser); use Socket; my $path = $ENV{PATH_INFO}; die "No hostname given" unless defined $path; my $pip = gethostbyname(substr($path, 1)); my $ip = inet_ntoa($pip); print header(), $ip; __END__ =head1 NAME dns - Resolve DNS entries via HTTP =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS http://ip-address-of-helper/cgi-bin/dns/hostname-to-be-resolved =head1 DESCRIPTION B is a CGI script that simple looks up a given host's IP address. Why would you need that? If one box on your network doesn't have access to a DNS server, but another one does, and you know its IP address, and it runs a web server, you can get DNS entries resolved this way: http://ip-address-of-helper/cgi-bin/dns/hostname-to-be-resolved This will call the C CGI script on the helper host, which will run a C on C and send back the result via HTTP. =head1 EXAMPLES http://192.168.0.32/cgi-bin/dns/www.aol.com will send back something like HTTP/1.1 200 OK Date: Sun, 14 Mar 2004 03:18:22 GMT Server: Apache/1.3.23 (Unix) mod_perl/1.27 Connection: close Content-Type: text/html; charset=ISO-8859-1 205.188.145.214 =head1 LEGALESE Copyright 2004 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR 2004, Mike Schilli