내가 얻은 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
?
답변1
분명히 ip
MAC 주소(현재 ip link
(장치) 인터페이스에 있음)와 네트워크가 파손되었습니다 ip address
. 이 명령은 ip address
네트워크 주소를 표시합니다.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 6c:88:14:ba:cb:cc brd ff:ff:ff:ff:ff:ff
inet 10.7.7.57/22 brd 10.7.7.255 scope global dynamic noprefixroute wlp3s0
valid_lft 1203509sec preferred_lft 1203509sec
inet6 2620:0:28a2:4010:2:2:8c75:f8a1/128 scope global dynamic noprefixroute
valid_lft 1203512sec preferred_lft 598712sec
inet6 fe80::440:3794:6794:8b1b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
-br
이는 보다 간결하고 사용자 친화적인(ief) 형식으로 볼 수 있습니다.
$ ip -4 -br addr show
lo UNKNOWN 127.0.0.1/8
wlp3s0 UP 10.7.7.57/22
-o
또는 한 줄( ) 로 볼 수도 있습니다 .
$ ip -o address
1: lo inet 127.0.0.1/8 scope host lo\ valid_lft forever preferred_lft forever
1: lo inet6 ::1/128 scope host \ valid_lft forever preferred_lft forever
3: wlp3s0 inet 10.7.7.57/22 brd 10.7.7.255 scope global dynamic noprefixroute wlp3s0\ valid_lft 1202464sec preferred_lft 1202464sec
3: wlp3s0 inet6 2620:0:28a2:4010:2:2:8c75:f8a1/128 scope global dynamic noprefixroute \ valid_lft 1202466sec preferred_lft 597666sec
3: wlp3s0 inet6 fe80::440:3794:6794:8b1b/64 scope link noprefixroute \ valid_lft forever preferred_lft forever