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

おすすめ記事