如何用python 取得小鸡的网卡名字?

cbacn2月前16 次点击



想取得第一张网卡的名字 eth0,eno1等等

用python怎么弄呢?

比如运行  ifconfig,取得第一网卡的名字 etho


[email protected]azure:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.0.4  netmask 255.255.255.0  broadcast 10.0.0.255
        inet6 fe80::217:faff:fe00:dab9  prefixlen 64  scopeid 0x20<link>
        ether 00:17:fa:00:da:b9  txqueuelen 1000  (Ethernet)
        RX packets 9507821  bytes 6398602710 (6.3 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 11484130  bytes 6409852499 (6.4 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

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 54792  bytes 5113693 (5.1 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 54792  bytes 5113693 (5.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
最新回复 (7) 直到 2019-05-18 12:01
返回