BASH 从 MAC 地址获取 OUI 供应商信息的命令行方法

BASH command-line method to obtain OUI vendor info from MAC address

我正在尝试重现旧 UnixStackExchange post 中概述的方法,使用 curl 命令使用本地获得的 MAC 地址搜索供应商名称。命令为:

curl -sS "http://standards-oui.ieee.org/oui.txt" | grep -i “$OUI” |剪切-d')'-f2 | tr -d 't'

然而,当我运行它时,它什么也没有产生。我已验证“OUI”包含我的 MAC 地址进行搜索。示例:

回显$OUI

EC-58-EA

这是因为 HTTP 服务器 return 一个 301 Moved Permanently 响应

➜  ~ curl http://standards-oui.ieee.org/oui.txt -i
HTTP/1.1 301 Moved Permanently
Server: nginx/1.12.0
Date: Sun, 07 Mar 2021 05:41:37 GMT
Content-Type: text/html
Content-Length: 185
Location: http://standards-oui.ieee.org/oui/oui.txt
Connection: keep-alive

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.12.0</center>
</body>
</html>

指示新位置 ---> < Location: http://standards-oui.ieee.org/oui/oui.txt

您可以 curl 新位置 o 告诉 curl 遵循 301 重定向:curl -L http://standards-oui.ieee.org/oui.txt

测试

➜  ~ curl -LsS "http://standards-oui.ieee.org/oui.txt" | grep -i "EC-58-EA" | cut -d')' -f2 | tr -d 't'
        Ruckus Wireless