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 593 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 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
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

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

      S 1 Reply Last reply
      1
      • JoeCFDJ JoeCFD

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

        S Offline
        S Offline
        SilentWolf
        wrote on 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

        • Login

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