Ip

無法解析 Vagrant VM 中 eth1 的 IP 地址

  • March 5, 2015

在執行ifconfig命令時,我得到以下輸出。eth1我需要用於執行我的 python 伺服器埠的 IP 地址。

eth0      Link encap:Ethernet  HWaddr 08:00:27:CE:08:3D
         inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
         inet6 addr: fe80::a00:27ff:fece:83d/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:2474 errors:0 dropped:0 overruns:0 frame:0
         TX packets:1511 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:204674 (199.8 KiB)  TX bytes:158605 (154.8 KiB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:18:CF:85
         inet6 addr: **fe80::a00:27ff:fe18:cf85/64** Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:20998 errors:0 dropped:0 overruns:0 frame:0
         TX packets:42 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:1648690 (1.5 MiB)  TX bytes:10524 (10.2 KiB)

lo        Link encap:Local Loopback
         inet addr:127.0.0.1  Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING  MTU:65536  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
         inet6 addr: fe80::1/128 Scope:Link
         UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
         RX packets:5 errors:0 dropped:0 overruns:0 frame:0
         TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:340 (340.0 b)  TX bytes:515 (515.0 b)

inet6 addr: fe80::a00:27ff:fe18:cf85/64foreth1不是標準 IP 地址格式。我該怎麼做才能獲得IP地址eth1

編輯 1ip命令的結果:

[root@localhost config]# ip a l dev eth1
eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
   link/ether 08:00:27:18:cf:85 brd ff:ff:ff:ff:ff:ff
   inet6 fe80::a00:27ff:fe18:cf85/64 scope link 
      valid_lft forever preferred_lft forever

fe80::/64是保留給Link-local的 ipv6 地址。ip a l dev eth1應該足以在此特定介面上顯示您的 IP 地址(如果通過 dhcp 伺服器分配或獲取)。

值得一讀

引用自:https://unix.stackexchange.com/questions/188413