Performing a Reverse DNS Lookup

You can use a simple technique that relies on xp_cmdshell to perform a reverse DNS lookup.

Brian Moran

July 18, 2005

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Is it possible to perform a reverse DNS lookup in a stored procedure or from a SQL Server Agent job?

You can use a simple technique that relies on xp_cmdshell to perform a reverse DNS lookup. Xp_cmdshell can be a security risk if not managed properly, but it can also be a powerful tool for doing specialized tasks in a controlled manner from T-SQL. For example, you can use the following code, then manipulate the output any way you need to.

DECLARE @OSCmd varchar(8000)DECLARE @DomainName varchar(8000)SET @DomainName  = 'www.solidqualitylearning.com'SET @OSCmd = 'NSLOOKUP ' + @DomainNameEXEC master.dbo.xp_cmdshell @OSCmd
Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like