列出一段时间内或从特定日期开始的 Mac 本地 IP 地址历史记录
如果你发现自己需要了解特定Mac分配的本地IP地址的历史,你可以从命令行中找到这个潜在的有用的网络信息。这个技巧将报告所有被Mac使用过的本地IP地址,而且,非常有用的是,它还将提供一个特定的IP地址被分配给Mac的具体日期和时间。是的,这些数据跨越了网络,即使它不再是机器的活动IP也适用。
如果你想知道为什么这可能是有帮助的,IP地址历史对于网络故障排除是非常有价值的,比如恼人的同一IP错误,系统和网络管理,数字取证,以及可能还有其他任务。
获取分配给Mac的本地IP地址的列表
下面的命令将获得一个给定Mac上所有本地分配的IP地址的完整列表:
cat /var/log/wifi.log |grep "Local IP" |less
这种输出的一个例子是这样的,请记住,输出可能非常长,这取决于wifi.log文件的大小和Mac的年龄,因此,通过管道少或多的结果,以方便阅读。如果你想把完整的历史记录转储到命令行中,就把最后的管道 “|less” 省掉:
Sat Jul 4 15:23:00.296
wl0: setup_keepalive: Local IP: 192.168.1.139
Sat Jul 4 16:24:05.694
wl0: setup_keepalive: Local IP: 192.168.1.139
Sat Jul 4 16:45:32.476
wl0: setup_keepalive: Local IP: 192.168.1.139
Sat Jul 4 20:22:31.770
wl0: setup_keepalive: Local IP: 192.168.1.139
Sun Jul 5 10:38:38.518
wl0: setup_keepalive: Local IP: 192.168.1.139
Sun Jul 5 20:21:48.599
wl0: setup_keepalive: Local IP: 192.168.1.139
Mon Jul 6 02:28:09.715
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 02:43:17.257
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 04:56:42.701
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 05:11:46.536
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 16:59:42.216
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 19:11:29.563
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 19:59:55.667
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 22:11:50.543
wl0: setup_keepalive: Local IP: 192.168.1.142
Mon Jul 6 22:26:56.589
wl0: setup_keepalive: Local IP: 192.168.1.142
Tue Jul 7 00:38:51.855
wl0: setup_keepalive: Local IP: 192.168.1.14
Tue Jul 7 00:53:55.393
wl0: setup_keepalive: Local IP: 192.168.1.14
Tue Jul 7 21:04:15.704
wl0: setup_keepalive: Local IP: 192.168.1.14
Tue Jul 7 22:05:00.573
wl0: setup_keepalive: Local IP: 192.168.1.14
Tue Jul 7 22:06:15.692
wl0: setup_keepalive: Local IP: 192.168.1.14
Tue Jul 7 23:07:00.554
wl0: setup_keepalive: Local IP: 192.168.1.12
Tue Jul 7 23:08:15.577
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 00:27:41.617
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 02:16:26.556
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 02:17:41.587
wl0: setup_keepalive: Local IP: 192.168.1.12
Wed Jul 8 04:06:26.555
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 04:07:41.605
wl0: setup_keepalive: Local IP: 192.168.1.12
Wed Jul 8 05:56:26.566
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 05:57:40.226
wl0: setup_keepalive: Local IP: 192.168.1.12
Wed Jul 8 07:01:33.566
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 08:17:18.563
wl0: setup_keepalive: Local IP: 192.168.1.12
Wed Jul 8 10:59:16.586
wl0: setup_keepalive: Local IP: 192.168.1.14
Wed Jul 8 11:34:45.866
wl0: setup_keepalive: Local IP: 192.168.1.12
Wed Jul 8 20:52:50.550
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 22:19:41.216
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 22:22:06.838
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 22:24:44.172
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 22:27:09.892
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 22:29:37.016
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 22:31:21.625
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 23:31:32.612
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 23:33:58.271
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 23:36:24.034
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 8 23:38:08.778
wl0: setup_keepalive: Local IP: 192.168.0.1
Thu Jul 9 01:22:14.939
wl0: setup_keepalive: Local IP: 192.168.0.1
Thu Jul 9 01:24:40.627
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 00:51:33.181
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 02:40:18.606
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 04:11:02.478
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 05:59:47.615
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 07:00:48.608
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 08:01:33.610
wl0: setup_keepalive: Local IP: 192.168.0.1
Sun Jul 12 09:02:18.613
wl0: setup_keepalive: Local IP: 192.168.0.7
Sun Jul 12 09:18:30.315
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 10:41:23.334
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 11:42:08.615
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 17:18:43.755
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 18:58:09.198
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 20:02:17.617
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 21:30:15.170
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 23:01:01.241
wl0: setup_keepalive: Local IP: 192.168.0.2
Sun Jul 12 23:51:46.368
wl0: setup_keepalive: Local IP: 192.168.0.2
Mon Jul 13 00:52:31.643
wl0: setup_keepalive: Local IP: 192.168.0.7
Mon Jul 13 02:41:16.616
wl0: setup_keepalive: Local IP: 192.168.0.7
Mon Jul 13 04:12:01.890
wl0: setup_keepalive: Local IP: 192.168.0.7
Mon Jul 13 05:57:46.613
wl0: setup_keepalive: Local IP: 192.168.0.7
Mon Jul 13 07:00:52.609
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 16:19:32.460
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 17:20:17.612
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 18:21:02.613
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 19:21:47.610
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 20:01:53.611
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 21:32:38.610
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 22:03:23.452
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 22:35:51.691
wl0: setup_keepalive: Local IP: 192.168.0.7
Tue Jul 14 23:06:56.536
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 15 00:52:40.897
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 02:41:24.535
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 04:12:09.169
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 05:57:54.613
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 07:01:51.680
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 08:02:35.502
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 09:03:20.606
wl0: setup_keepalive: Local IP: 192.168.0.4
Wed Jul 15 10:11:26.677
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 15 12:25:08.484
wl0: setup_keepalive: Local IP: 192.168.0.7
Wed Jul 15 15:09:38.001
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 04:11:13.624
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 05:59:58.628
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 07:01:45.087
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 08:02:30.605
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 09:03:15.618
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 10:04:31.065
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 12:44:06.798
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 16:10:53.498
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 16 17:39:54.537
wl0: setup_keepalive: Local IP: 192.168.0.7
这显然是相当多的数据,这就是为什么它通过管道少,或者你可以重定向到一个文本文件,如果你想在其他地方审查它。
寻找特定日期或时间的Macs IP地址
另一个选择是专门搜索在某个特定日期使用的本地分配的IP地址。使用的格式是YYY ZZZ XX,其中YYY是一天的前三个字母,ZZZ是月份的前三个字母,XX是数字日期。例如:
cat /var/log/wifi.log |grep "Local IP" |grep "Thu Jul 23"
这将只报告符合该日期的条目:
$ cat /var/log/wifi.log |grep "Local IP" |grep "Thu Jul 23"
Thu Jul 23 00:07:53.688
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 23 01:56:38.622
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 23 02:23:07.227
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 23 04:11:52.817
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 23 06:00:37.623
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 23 07:01:21.625
wl0: setup_keepalive: Local IP: 192.168.0.7
Thu Jul 23 08:50:06.748
wl0: setup_keepalive: Local IP: 192.168.0.7
如果需要,你可以更具体地搜索分配IP地址的时间,如果你要用grep来搜索,记得要用24小时的时间,并考虑到时间信息是由本地机器的时区设置决定。
为了进一步发现或排除故障,你可以将wifi.log中发现的数据与连接的wi-fi网络的历史进行比较,以发现更多的细节,或对特定路由器的IP问题进行补救。
值得注意的是,一些现代版本的MacOS不包括wifi.log中的本地IP信息,但早期版本的MacOS和Mac OS X却包括,所以如果你在扫描日志文件时没有找到你要的信息,请考虑使用的是哪个版本的MacOS。
如果你知道任何其他与特定机器的本地IP地址历史有关的有用技巧,请在评论中告诉我们。