在运行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/64
foreth1
不是标准 IP 地址格式。我该怎么做才能获取IP地址eth1
编辑1:命令结果ip
:
[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
答案1
fe80::/64
是保留给的 ipv6 地址链接本地。ip a l dev eth1
应该足以显示您在此特定接口上的 IP 地址(如果通过 dhcp 服务器分配或获取)。
值得一读: