Jessie 및 Stretch에서 eth0 IP를 확인하는 안정적인 명령

Jessie 및 Stretch에서 eth0 IP를 확인하는 안정적인 명령

그래서 어떤 천재가 인쇄 방식을 바꿨습니다. Raspbian을 사용하는 Raspberry(Debian Jessie):

$ /sbin/ifconfig eth0
eth0      Link encap:Ethernet  HWaddr b8:27:eb:71:d5:56  
      inet addr:192.168.0.11  Bcast:192.168.0.255  Mask:255.255.255.0
      inet6 addr: fe80::1e43:2c74:e7d6:6419/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:165 errors:0 dropped:0 overruns:0 frame:0
      TX packets:135 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:17459 (17.0 KiB)  TX bytes:18391 (17.9 KiB)

내 노트북(Debian Stretch)에서:

$ /sbin/ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.0.77  netmask 255.255.255.0  broadcast 192.168.0.255
    inet6 fe80::39db:8c13:722f:b088  prefixlen 64  scopeid 0x20<link>
    ether 40:b0:34:96:d9:02  txqueuelen 1000  (Ethernet)
    RX packets 118126  bytes 23261567 (22.1 MiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 319445  bytes 452933203 (431.9 MiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 16  memory 0xcc200000-cc220000  

"inet addr:"랩톱에서는 분명히 실패하는 구문 분석 코드가 있습니다 . 쉘 명령을 사용하여 Raspbian/Jessie 및 Stretch에서 eth0 IP 주소를 얻는 독특한 방법이 있습니까?

답변1

이는 두 시스템 모두에서 동일한 형식을 갖습니다.

$ ip a show eth0 # stretch
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 40:b0:34:96:d9:02 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.77/24 brd 192.168.0.255 scope global eth0
   valid_lft forever preferred_lft forever
inet6 fe80::39db:8c13:722f:b088/64 scope link tentative 
   valid_lft forever preferred_lft forever

$ ip a show eth0 # raspbian jessie
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:71:d5:56 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.11/24 brd 192.168.0.255 scope global eth0
   valid_lft forever preferred_lft forever
inet6 fe80::1e43:2c74:e7d6:6419/64 scope link 
   valid_lft forever preferred_lft forever

관련 정보