Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Get MAC address from IP of local network machine
Forum Updated to NodeBB v4.3 + New Features

Get MAC address from IP of local network machine

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 14.2k 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.
  • U Offline
    U Offline
    usamytch
    wrote on last edited by
    #1

    Good day, colleagues!

    I'm writing application that uses Winpcap(libpcap) and I need to create Ethernet packets manually. To do this, I must know MAC addresses of local and destination machines. Suppose that destination machine is in my local network (if it's not I need to know gateway MAC).

    As I understand, I can get local MAC with the help of @QNetworkInterface::hardwareAddress ().@ But getting MAC of remote machine is not so obvious. Can I do it with the help of QT or I must use system commands or packet capturing?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I don't think you can expect help from Qt on this. You will need to use system commands.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #3

        I do not know of anything within Qt that provides this level of information so I think that you will need to use some platform-specific code.

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • U Offline
          U Offline
          usamytch
          wrote on last edited by
          #4

          Thank you for the answers, I'll go to the system commands.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on last edited by
            #5

            OK, QProcess and arp spring to mind.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rich
              wrote on last edited by
              #6

              If you're creating raw packets anyway then just create an ARP request for the target IP address and look at the mac address in the ARP reply.

              1 Reply Last reply
              0
              • U Offline
                U Offline
                usamytch
                wrote on last edited by
                #7

                Thank you, on Windows @arp -a <IP>@ did the trick.

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  ZapB
                  wrote on last edited by
                  #8

                  [quote author="rich" date="1302263107"]If you're creating raw packets anyway then just create an ARP request for the target IP address and look at the mac address in the ARP reply.
                  [/quote]

                  I agree that this is probably a better way to go eventually - especially if this will be done for huge numbers of devices as launching processes is expensive. I just suggested QProcess and the arp tool as a way of getting something up and running quickly.

                  Nokia Certified Qt Specialist
                  Interested in hearing about Qt related work

                  1 Reply Last reply
                  0
                  • ? This user is from outside of this forum
                    ? This user is from outside of this forum
                    Guest
                    wrote on last edited by
                    #9

                    Code examples for arp -a might be found here...
                    http://beej.us/guide/bgnet/output/html/multipage/index.html

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved