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. .NET (Core and Framework)
  4. Get MAC address only from internal ethernet connection

Get MAC address only from internal ethernet connection

Scheduled Pinned Locked Moved .NET (Core and Framework)
sysadminhelptutorial
7 Posts 2 Posters 0 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.
  • B Offline
    B Offline
    blueye89
    wrote on last edited by
    #1

    Hello to all, I am struggling to find a way to get MAC address ONLY from the ethernet card in my PC. It's easy when my PC is not connected on the VPN:

    Function getMacAddress()
    Dim nics() As NetworkInterface = _
    NetworkInterface.GetAllNetworkInterfaces
    Return nics(0).GetPhysicalAddress.ToString
    End Function

    But if it's already connected then the first (0) device is ethernet card of the server that I'm connected and my ethernet is second (1) device so I don't know how to determine. This is showed on the image on this link: https://postimg.org/image/4ndewjjhz/ Any help is very appreciated!

    D 1 Reply Last reply
    0
    • B blueye89

      Hello to all, I am struggling to find a way to get MAC address ONLY from the ethernet card in my PC. It's easy when my PC is not connected on the VPN:

      Function getMacAddress()
      Dim nics() As NetworkInterface = _
      NetworkInterface.GetAllNetworkInterfaces
      Return nics(0).GetPhysicalAddress.ToString
      End Function

      But if it's already connected then the first (0) device is ethernet card of the server that I'm connected and my ethernet is second (1) device so I don't know how to determine. This is showed on the image on this link: https://postimg.org/image/4ndewjjhz/ Any help is very appreciated!

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      No, it's NOT the network interface of the server you're connected to. You cannot get remote MAC adresses. What you're getting is the MAC of the virtual network adapter created by the VPN software. Dump the data on all the adapters returned, not just the first one.\ MAC addresses are not assigned to machines. They are assigned by the manufactures of the network adapters, or a generated in software for the adapter. MAC's can NOT be used as a unique identifier for any purpose. They are NOT unique to any machine!

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      B 1 Reply Last reply
      0
      • D Dave Kreskowiak

        No, it's NOT the network interface of the server you're connected to. You cannot get remote MAC adresses. What you're getting is the MAC of the virtual network adapter created by the VPN software. Dump the data on all the adapters returned, not just the first one.\ MAC addresses are not assigned to machines. They are assigned by the manufactures of the network adapters, or a generated in software for the adapter. MAC's can NOT be used as a unique identifier for any purpose. They are NOT unique to any machine!

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        B Offline
        B Offline
        blueye89
        wrote on last edited by
        #3

        Hi Dave, So what do you suggest to use as the unique identifier?

        D 1 Reply Last reply
        0
        • B blueye89

          Hi Dave, So what do you suggest to use as the unique identifier?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          You didn't say thing about the type of app you're writing, but typically, I'd generate a GUID and send that to the client and it stores it appropriately, passing it back to the server as appropriate when needed.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          B 1 Reply Last reply
          0
          • D Dave Kreskowiak

            You didn't say thing about the type of app you're writing, but typically, I'd generate a GUID and send that to the client and it stores it appropriately, passing it back to the server as appropriate when needed.

            Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
            Dave Kreskowiak

            B Offline
            B Offline
            blueye89
            wrote on last edited by
            #5

            Actually I have made an Windows Form application and I am trying to protect it by giving a specific activation code generated by some machine id or something like that. I read about many different ways of getting unique hardware serials but there is no perfect solution cause hardware components can be cloned or replaced. I agree with you about activation through server but I would like to make possibility to make also offline registration.

            D 1 Reply Last reply
            0
            • B blueye89

              Actually I have made an Windows Form application and I am trying to protect it by giving a specific activation code generated by some machine id or something like that. I read about many different ways of getting unique hardware serials but there is no perfect solution cause hardware components can be cloned or replaced. I agree with you about activation through server but I would like to make possibility to make also offline registration.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Honestly, the copy protection problem has never been solved, by any vendor. It's a waste of your time and, more importantly, your customers time. My primary job is software repackaging for deployment in the enterprise environment. Trust me when I tell you, as a customer, licensing is a giant pain in the ass. Normally, vendors use the data submitted about the customer, such as company name, contact name, phone number, address, email address, and whatnot, run all that through an algorithm to generate a license key file. That license file is checked for validity by the application on launch. But, in all cases, if someone wanted to hack your app and take out the license validation, there's nothing you can do to stop them. DO NOT TRY AND "ROLL YOUR OWN" LICENSING SOLUTION. You'll end up making it ridiculously easy to break. Use a commercial solution. Google for "C# licensing framework".

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
              Dave Kreskowiak

              B 1 Reply Last reply
              0
              • D Dave Kreskowiak

                Honestly, the copy protection problem has never been solved, by any vendor. It's a waste of your time and, more importantly, your customers time. My primary job is software repackaging for deployment in the enterprise environment. Trust me when I tell you, as a customer, licensing is a giant pain in the ass. Normally, vendors use the data submitted about the customer, such as company name, contact name, phone number, address, email address, and whatnot, run all that through an algorithm to generate a license key file. That license file is checked for validity by the application on launch. But, in all cases, if someone wanted to hack your app and take out the license validation, there's nothing you can do to stop them. DO NOT TRY AND "ROLL YOUR OWN" LICENSING SOLUTION. You'll end up making it ridiculously easy to break. Use a commercial solution. Google for "C# licensing framework".

                Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
                Dave Kreskowiak

                B Offline
                B Offline
                blueye89
                wrote on last edited by
                #7

                Dave, Thank you so much for the great advice! I will keep in mind all your words. All the best, Danijel

                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