Is there any way to get MAC address of remote IP (Same LAN) with QT code?
Solved
General and Desktop
-
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 wlp0s20f3But I don't know how to get MAC address of 192.168.2.222 with Qt code
-
https://stackoverflow.com/questions/45081979/check-ip-active-address-with-qt
arp scan is there. -
https://stackoverflow.com/questions/45081979/check-ip-active-address-with-qt
arp scan is there.@JoeCFD thank you
I got address by arp -a with bellow codeQString 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 ""; }