2017-01-13 15 views
1

Dears я планировал извлечь маску подсети, я использовал код ниже, но в маску подсети всегда 255.255.255.255 что неправильноИзвлечение маски подсети из моего компьютера питона

Выходной код :

IPAddress: 192.168.1.4 
Mask: 255.255.255.255 
Gateway: 192.168.1.1 
IP Address: 192.168.231.1 
Mask: 255.255.255.255 
Gateway: 192.168.1.1 
IP Address: 192.168.116.1 
Mask: 255.255.255.255 
Gateway: 192.168.1.1 
IP Address: 10.255.90.137 
Mask: 255.255.255.255 
Gateway: 192.168.1.1 
IP Address: 127.0.0.1 
Mask: 255.255.255.255 
Gateway: 192.168.1.1 

выходной сигнал IPconfig/все на CMD:

IPCONFIG/ALL

Windows IP Configuration 

    Host Name . . . . . . . . . . . . 
    Primary Dns Suffix . . . . . . . 
    Node Type . . . . . . . . . . . . : Peer-Peer 
    IP Routing Enabled. . . . . . . . : No 
    WINS Proxy Enabled. . . . . . . . : No 
    DNS Suffix Search List. . . . . . : 

             Home 

Wireless LAN adapter Wireless Network Connection 2: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : 
    Description . . . . . . . . . . . : Microsoft Virtual WiFi Miniport Adapter 
    Physical Address. . . . . . . . 
    DHCP Enabled. . . . . . . . . . . : Yes 
    Autoconfiguration Enabled . . . . : Yes 

Wireless LAN adapter Wireless Network Connection: 

    Connection-specific DNS Suffix . : Home 
    Description . . . . . . . . . . . : Broadcom 802.11n Network Adapter 
    Physical Address. . . . . . . . . : E4-D5-3D 
    DHCP Enabled. . . . . . . . . . . : Yes 
    Autoconfiguration Enabled . . . . : Yes 
    Link-local IPv6 Address . . . . . : fe80::9075:a791:%18(Preferred) 
    IPv4 Address. . . . . . . . . . . : 192.168.1.4(Preferred) 
    Subnet Mask . . . . . . . . . . . : 255.255.255.0 
    Lease Obtained. . . . . . . . . . : Thursday, January 12, 2017 4:24:27 PM 
    Lease Expires . . . . . . . . . . : Friday, January 13, 2017 5:32:47 PM 
    Default Gateway . . . . . . . . . : 192.168.1.1 
    DHCP Server . . . . . . . . . . . : 192.168.1.1 
    DHCPv6 IAID . . . . . . . . . . . : 585422141 
    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-7C-BD-0D-28-D2- 

    DNS Servers . . . . . . . . . . . : 192.168.1.1 
             192.168.1.1 
    NetBIOS over Tcpip. . . . . . . . : Enabled 

Ethernet adapter Local Area Connection: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : Home 
    Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller #2 
    Physical Address. . . . . . . . . : F0-DE 
    DHCP Enabled. . . . . . . . . . . : Yes 
    Autoconfiguration Enabled . . . . : Yes 

Ethernet adapter VMware Network Adapter VMnet1: 

    Connection-specific DNS Suffix . : 
    Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet 
1 
    Physical Address. . . . . . . . . : 00-50-56-C0-00-01 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 
    Link-local IPv6 Address . . . . . : fe80::bd6e:92d5%29(Preferred) 
    IPv4 Address. . . . . . . . . . . : 192.168.231.1(Preferred) 
    Subnet Mask . . . . . . . . . . . : 255.255.255.0 
    Default Gateway . . . . . . . . . : 
    DHCPv6 IAID . . . . . . . . . . . : 486559830 
    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-7C-BD-0D-28-D2 

    DNS Servers . . . . . . . . . . . : fec0:0:0:f::1%1 
             fec0:0:0:ffff::2%1 
             fec0:0:0:ffff::3%1 
    NetBIOS over Tcpip. . . . . . . . : Enabled 

Ethernet adapter VMware Network Adapter VMnet8: 

    Connection-specific DNS Suffix . : 
    Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet 
8 
    Physical Address. . . . . . . . . : 00-50-56-C0-00-08 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 
    Link-local IPv6 Address . . . . . : fe80::ecf8:fe3f:61b7%30(Preferred) 
    IPv4 Address. . . . . . . . . . . : 192.168.116.1(Preferred) 
    Subnet Mask . . . . . . . . . . . : 255.255.255.0 
    Default Gateway . . . . . . . . . : 
    DHCPv6 IAID . . . . . . . . . . . : 5033046 
    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1CD-0D-28-D2-44-A0-5E-2F 

    DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1 
             fec0:0:0:ffff::2%1 
             fec0:0:0:ffff::3%1 
    NetBIOS over Tcpip. . . . . . . . : Enabled 

Ethernet adapter Local Area Connection* 13: 

    Connection-specific DNS Suffix . : te-data.core 
    Description . . . . . . . . . . . : Juniper Networks Virtual Adapter 
    Physical Address. . . . . . . . . : 02-05-85-7F-EB-80 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 
    Link-local IPv6 Address . . . . . : fe80::60c5:1d5a::3ac%32(Preferred) 
    IPv4 Address. . . . . . . . . . . : 10.255.90.137(Preferred) 
    Subnet Mask . . . . . . . . . . . : 255.255.255.255 
    Default Gateway . . . . . . . . . : 
    DHCPv6 IAID . . . . . . . . . . . : 989988229 
    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1C-7C-BD-0D-28-D2-44-A0-5E-2F 

    DNS Servers . . . . . . . . . . . : 10.11.244.6 
             10.11.240.21 
    Primary WINS Server . . . . . . . : 10.11.244.5 
    NetBIOS over Tcpip. . . . . . . . : Enabled 

Tunnel adapter isatap.{8F32F9B4-16AA-497F-BA87-0CA6C100DAD2}: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : 
    Description . . . . . . . . . . . : Microsoft ISATAP Adapter 
    Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 

Tunnel adapter isatap.te-data.core: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : te-data.core 
    Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2 
    Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 

Tunnel adapter isatap.{72AB26AD-F4AC-4C29-BE57-D5E87178132D}: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : 
    Description . . . . . . . . . . . : Microsoft ISATAP Adapter #3 
    Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 

Tunnel adapter isatap.Home: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : Home 
    Description . . . . . . . . . . . : Microsoft ISATAP Adapter #4 
    Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 

Tunnel adapter isatap.{C6CA3E0D-C7E1-4B41-BDAB-74703EB3BC2C}: 

    Media State . . . . . . . . . . . : Media disconnected 
    Connection-specific DNS Suffix . : 
    Description . . . . . . . . . . . : Microsoft ISATAP Adapter #5 
    Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0 
    DHCP Enabled. . . . . . . . . . . : No 
    Autoconfiguration Enabled . . . . : Yes 
+0

Код работает отлично для меня. Можете ли вы показать свой вывод и, может быть, вывод из ifconfig/ipconfig? –

+0

Я добавил вывод в главном сообщении, спасибо @StephenRauch –

ответ

0

Есть альтернативы netifaces на Windows. Вы можете получить информацию о интерфейсе, используя wmic. wmic имеет читаемый вариант вывода аппарата с помощью XML:

wmic nic get /format:rawxml 

питона пример parse this output доступен.

 Смежные вопросы

  • Нет связанных вопросов^_^