ifconfig, netstat -nr, traceroute的使用即详析
一、ifconfig


看的一脸懵逼,这都什么东西。。。
networksetup -listallhardwareports一下,加上各种百度,谷歌。。。

更进一步地,终端输入:
defaults read /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
得到en0 - en7的详细信息。



小结一下:
lo0 = 本地环回(lo is the loopback interface)
gif0 = Software Network Interface, 通用 IP-in-IP隧道(RFC2893)
stf0 = IPv6转IPv4的接口(stf0 is an IPv6 to IPv4 tunnel interface. It's a bridge connection that exists to help us transition from IPv4 to the IPv6 standard.)
XHC0, 1, 20 = USB接口(这三个应该是我外接Type-C拓展坞的三个USB接口)
en0 = Wi-Fi接口
en1 = 雷雳接口1
en2 = 雷雳接口2
en3 = 雷雳接口3
en4 = 雷雳接口4
en5 = USB 10/100/1000 LAN(应该是我外接Type-C拓展坞的那个网络接口)
en6 = 蓝牙
en7 = Apple T1 Controller(T1芯片控制端口)
p2p0 = p2p0 is a point to point link (usually VPN)
awdl0 = awdl0 is Apple Wireless Direct Link (Bluetooth) to iOS devices
bridge0 = bridge0 is a software bridge between other interfaces
utun0 = utun0 is used for "Back to My Mac"
ppp0 = ppp0是经以太网接口PPP拨号时创建的链路接口,用以建立PPP拨号连接 的,通常依赖于eth接口。也就是说eth是实体接口,ppp是构建于eth之 上的虚拟接口。
(若要了解ifconfig的更多用法,可以在终端输入info ifconfig)
二、netstat -nr(也可在 Mac 上,打开“网络实用工具”应用 ,位于“/系统/资源库/CoreServices/Applications”文件夹中。然后点按“Netstat”。)
要了解netstat 的更过用法,终端输入:info netstat

初略看下Destination应该是目的IP地址,Gateway是网关,后面就不知道了
终端输入:man netstat


这就得到了Flags中每个字母代表的是什么含义,
Flags field shows a collection of information about the route stored as binary choices.
Ref field gives the current number of active uses of the route.
Use field provides a count of the number of packets sent using that route.
Expire is a timeout - a period in which the host doesn't respond to that route.
Netif 应该是发送接口。

以这一行为例,目的地址是100.73.136.1(公网IP),这是个A类地址,下一跳是100.73.139.106,Flags是UH代表路径可用,主机接入;Ref和Use都0,还没有数据包发送,Netif为ppp0,发送接口。
三、traceroute 科大官网
终端输入:traceroute www.ustc.edu.cn

分析:Traceroute能够显示到达目的地址所需的跳数、经过的路由器的IP地址、延时、丢包情况等信息。第一跳为221.178.235.9,第二跳为183.213.36.89,第三跳为221.183.47.9;每条记录输出3个延时结果,说明源地址每次默认发送三个数据包;在第三条只有2个延时结果,说明源地址只收到了2个ICMP超时通知消息。四五两行是以星号表示的。出现这样的情况,可能是防火墙封掉了ICMP的返回信息,所以我们得不到什么相关的数据包返回数据。最后的目的地址为202.141.176.6

浙公网安备 33010602011771号