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. Is there any way to get MAC address of remote IP (Same LAN) with QT code?

Is there any way to get MAC address of remote IP (Same LAN) with QT code?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 592 Views
  • 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.
  • S Offline
    S Offline
    SilentWolf
    wrote on 26 Aug 2021, 17:42 last edited by
    #1

    I can see MAC address by terminal command:
    ~$ arp -a
    _gateway (192.168.2.1) at f8:1a:67:7c:78:1c [ether] on wlp0s20f3
    ? (192.168.2.104) at 48:b0:2d:3e:6e:b4 [ether] on wlp0s20f3
    ? (192.168.2.222) at 00:17:61:10:a9:47 [ether] on wlp0s20f3
    ? (192.168.2.100) at ea:23:dc:ae:66:e4 [ether] on wlp0s20f3

    But I don't know how to get MAC address of 192.168.2.222 with Qt code

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JoeCFD
      wrote on 26 Aug 2021, 17:48 last edited by
      #2

      https://stackoverflow.com/questions/45081979/check-ip-active-address-with-qt
      arp scan is there.

      S 1 Reply Last reply 27 Aug 2021, 17:24
      1
      • J JoeCFD
        26 Aug 2021, 17:48

        https://stackoverflow.com/questions/45081979/check-ip-active-address-with-qt
        arp scan is there.

        S Offline
        S Offline
        SilentWolf
        wrote on 27 Aug 2021, 17:24 last edited by
        #3

        @JoeCFD thank you
        I got address by arp -a with bellow code

        QString getMacAddress(QString Ip)
        {
            QString outCmd, error;
            QProcess process;
            process.start("arp -a " + Ip);
            process.waitForFinished();
            outCmd = process.readAllStandardOutput();
            error = process.readAllStandardError();
        
        //    outCmd = "? (192.168.2.222) at 00:17:61:10:a9:47 [ether] on eth0\n";
        
            if(error.isEmpty()) {
                QRegularExpression re(QStringLiteral("([a-fA-F0-9][a-fA-F0-9]:){5}[0-9a-fA-F][0-9a-fA-F]"));
                QRegularExpressionMatch match = re.match(outCmd);
                if(match.hasMatch()){
                    return match.captured(0);
                }
            }
            return "";
        }
        
        1 Reply Last reply
        0

        2/3

        26 Aug 2021, 17:48

        • Login

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