In addition to what CF said, you may be interested in the following from the help file (/help on DNS)

Quote:

on DNS

The on DNS event triggers when a /dns query either succeeds or fails.

Format: on <level>:DNS:<commands>
Example: on 1:DNS:/notice $me Resolved: $raddress

Examples
Code:
on 1:DNS:{
  var %n = $dns(0)
  echo 4 Found %n addresses
  while (%n &gt; 0) {
    echo 4 dns: $dns(%n) nick: $dns(%n).nick addr: $dns(%n).addr ip: $dns(%n).ip
    dec %n
  }
}

Note: This event is also triggered if you try to /dns a nickname, and the nickname is not
on IRC.

The $dns(N) identifier
This identifier can be used only in the on DNS event, and returns the address that was
resolved and any associated IP addresses.

Properties: nick, addr, ip

$dns(N) without a property returns the address being resolved.

You can use N = 0 to return the number of addresses found.

You can use $dns(0).nick/addr/ip to reference properties if an address couldn't be
resolved.


Hope it helps