Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reverse IP Lookup in C#/.NET

Reverse IP Lookup in C#/.NET

Scheduled Pinned Locked Moved C#
csharpquestiondotnettutorial
6 Posts 4 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quimbly
    wrote on last edited by
    #1

    I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!

    D J I 3 Replies Last reply
    0
    • Q Quimbly

      I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!

      D Offline
      D Offline
      Daniel Turini
      wrote on last edited by
      #2

      I don't know... Maybe trying a Interop call to NetWkstaGetInfo and passing the computer name as "\\x.x.x.x" ?? :confused: Q261186 - Computer Randomly Plays Classical Music

      1 Reply Last reply
      0
      • Q Quimbly

        I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!

        J Offline
        J Offline
        Jon Rista
        wrote on last edited by
        #3

        This is on a windows network? There is the WNet api in the PlatformSDK. You might be able to import functions from the windows networking DLL's to access windows networking information like computer names (wouldn't that be NetBIOS?).

        Q 1 Reply Last reply
        0
        • J Jon Rista

          This is on a windows network? There is the WNet api in the PlatformSDK. You might be able to import functions from the windows networking DLL's to access windows networking information like computer names (wouldn't that be NetBIOS?).

          Q Offline
          Q Offline
          Quimbly
          wrote on last edited by
          #4

          No, this is not specific to a Windows network. I need to be able to get the "computer name" of any in-coming IP address to the firewall. Basically, I want my app to be able to do what a NSLOOKUP call does. Get what I mean?

          J 1 Reply Last reply
          0
          • Q Quimbly

            No, this is not specific to a Windows network. I need to be able to get the "computer name" of any in-coming IP address to the firewall. Basically, I want my app to be able to do what a NSLOOKUP call does. Get what I mean?

            J Offline
            J Offline
            Jon Rista
            wrote on last edited by
            #5

            Yeah, makes sense. Is there an RFC or public spec for what NSLOOKUP does? I'd search the net for something and see if you can figure out the message format for NSLOOKUP messages.

            1 Reply Last reply
            0
            • Q Quimbly

              I'm developing a firewall log monitoring application in C# with the .NET framework, and I can't figure out something. I'm trying to do a reverse lookup on an IP address. I don't mean reverse lookup to a DNS entry. I'm looking to find out the computer-name behind the IP address. The only thing I can find that's remotely related is: Dns.GetHostByName() and Dns.GetHostByAddress(). However,these methods deal with IPHost objects, which only contain DNS or IP information -- nothing about computer- name. Does anyone have any idea how to get a computer-name from an IP address in my C#/.NET application? Is there anything in .NET that will accomplish this? If so, what is it? If not, what can I call outside of .NET that I can incorporate into my application? Thanks!

              I Offline
              I Offline
              ian mariano
              wrote on last edited by
              #6

              If it's "across the wire" all you're going to get is the DNS reverse lookup. Machine names are not necessarily the same as the DNS name, and all TCP/IP w/DNS will give you is just that: The DNS name, which may or not be the machine name. NetWkstaGetInfo() will only work on Windows machines (Pre Windows 2000 or Pre Windows 2000 compatible) where Anonymous access is allowed (a reeeeely reeeeeely reeely bad practice!) Why do you need to know the actual machine name anyway? If there's suspicious behavior, you can trace the IP back. If it's illegal behavior, you can go deeper and give the authorities your firewall logs for the offense.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups