当我运行 ip 来获取 ip 地址时,我得到了
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether 6c:88:14:ba:cb:cc brd ff:ff:ff:ff:ff:ff
这些都不是ipv4地址,但是ifconfig
确实显示了,
$ sudo /sbin/ifconfig
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 1102801 bytes 74417671 (70.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1102801 bytes 74417671 (70.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.7.7.57 netmask 255.255.252.0 broadcast 10.7.7.255
inet6 fe80::440:3794:6794:8b1b prefixlen 64 scopeid 0x20<link>
inet6 2620:0:28a2:4010:2:2:8c75:f8a1 prefixlen 128 scopeid 0x0<global>
ether 6c:88:14:ba:cb:cc txqueuelen 1000 (Ethernet)
RX packets 32743430 bytes 48351612590 (45.0 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14856403 bytes 1590947780 (1.4 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我怎样才能获得 ipv4 信息而不会落入我已弃用(且值得信赖)的范围内ifconfig
?
显然
ip
破坏了 MAC 地址(现在在ip link
(设备)接口中)和网络ip address
。该命令ip address
是显示网络地址的内容,这可以在更紧凑和用户友好的 (
-br
ief) 格式中看到或者,您可以在一行 (
-o
) 中看到它,