例如,我用谷歌搜索并查看了此页面arp
,我知道该命令应该显示互联网协议(IP)地址和媒体访问控制(MAC)地址之间的映射。
但当我在 22.04 ubuntu 系统上查看输出时,它对我来说没有意义。这里arp
给出:
_gateway (192.168.107.172) at 3a:65:d4:6d:20:cf [ether] on wlp0s20f3
这里我假设有一个以太网适配器,其 MAC 地址3a:65:d4:6d:20:cf
具有 IP 地址192.168.107.172
。但是当我查看时,ifconfig
我没有看到这个IP地址:
enp84s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 7c:57:58:80:1c:61 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device memory 0x54000000-540fffff
enx00e04c680202: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.200.100 netmask 255.255.255.0 broadcast 192.168.200.255
ether 00:e0:4c:68:02:02 txqueuelen 1000 (Ethernet)
RX packets 124 bytes 11140 (11.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 28 bytes 2981 (2.9 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enxa0cec8c97ebc: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether a0:ce:c8:c9:7e:bc txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 13849 bytes 1664000 (1.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 13849 bytes 1664000 (1.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp0s20f3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.107.238 netmask 255.255.255.0 broadcast 192.168.107.255
inet6 fe80::6a85:ef4a:7e3c:be96 prefixlen 64 scopeid 0x20<link>
inet6 2a01:cb16:2068:7c6c:8e00:94e:c979:548e prefixlen 64 scopeid 0x0<global>
inet6 2a01:cb16:2068:7c6c:d2f4:5a68:7bd8:e5d7 prefixlen 64 scopeid 0x0<global>
ether 3c:e9:f7:a7:1c:0f txqueuelen 1000 (Ethernet)
RX packets 209228 bytes 203369040 (203.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 113025 bytes 26069725 (26.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我看到列出的适配器arp
(“wlp0s20f3”)的 IP 地址是 192.168.107.238,而不是 192.168.107.172!
我还使用了一个附加的 USB 以太网设备(“enx00e04c680202”),该设备未显示在 arp 列表中。USB 以太网适配器没有 MAC 地址吗?
ARP 协议旨在为您提供目标卡的物理地址,以便您的计算机可以与(不是您的)物理连接。
向您提供 IP 为 192.168.107.172 的网关的 MAC 地址为 3a:65:d4:6d:20:cf 的信息,以便您的卡可以请求连接或通话。
这是它的工作原理:
综上所述,ARP 提供了第 3 层(IP 地址)和第 2 层(MAC 地址)之间的关键链路,允许设备在本地网段上直接通信。
该命令
arp
显示您的计算机不久前使用的网络其他 IP 的远程 mac 地址。