Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

netmask is wrong on Windows 7 64bit #32

Open
pansila opened this issue Jan 10, 2019 · 2 comments
Open

netmask is wrong on Windows 7 64bit #32

pansila opened this issue Jan 10, 2019 · 2 comments

Comments

@pansila
Copy link

pansila commented Jan 10, 2019

I got a wrong netmask which is set statically as 255.255.255.0 in adapter's properties dialog while it's 255.255.255.255 from netifaces.

>>> for i in netifaces.interfaces():
...     if netifaces.AF_INET in netifaces.ifaddresses(i):
...         for address in netifaces.ifaddresses(i)[netifaces.AF_INET]:
...             print(address)
...
{'addr': '192.168.3.100', 'netmask': '255.255.255.0', 'broadcast': '192.168.3.255'}
{'addr': '192.168.1.2', 'netmask': '255.255.255.255', 'broadcast': '192.168.1.2'}
{'addr': '127.0.0.1', 'netmask': '255.0.0.0', 'broadcast': '127.255.255.255'}
@pansila
Copy link
Author

pansila commented Jan 10, 2019

It looks like an issue related to route table configuration. After I delete all route entries of 192.168.1.x, disable and enable the adapter to make route entries refreshed automatically, the issue is gone.

netifaces should find some way to look the netmask in adapter's properties dialog instead of some entry in route table.

Before clean-up

          0.0.0.0          0.0.0.0      192.168.3.1    192.168.3.100     26
          0.0.0.0          0.0.0.0      192.168.1.1      192.168.1.2    276
        127.0.0.0        255.0.0.0            On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255            On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255            On-link         127.0.0.1    306
      192.168.1.0    255.255.255.0      192.168.1.1      192.168.1.2     21
      192.168.1.2  255.255.255.255            On-link       192.168.1.2    276
      192.168.3.0    255.255.255.0            On-link     192.168.3.100    281
    192.168.3.100  255.255.255.255            On-link     192.168.3.100    281
    192.168.3.255  255.255.255.255            On-link     192.168.3.100    281
        224.0.0.0        240.0.0.0            On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0            On-link       192.168.1.2    276
        224.0.0.0        240.0.0.0            On-link     192.168.3.100    281
  255.255.255.255  255.255.255.255            On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255            On-link       192.168.1.2    276
  255.255.255.255  255.255.255.255            On-link     192.168.3.100    281

After clean-up.

          0.0.0.0          0.0.0.0      192.168.3.1    192.168.3.100     26
          0.0.0.0          0.0.0.0      192.168.1.1      192.168.1.2    276
        127.0.0.0        255.0.0.0            On-link         127.0.0.1    306
        127.0.0.1  255.255.255.255            On-link         127.0.0.1    306
  127.255.255.255  255.255.255.255            On-link         127.0.0.1    306
      192.168.1.0    255.255.255.0            On-link       192.168.1.2    276
      192.168.1.2  255.255.255.255            On-link       192.168.1.2    276
    192.168.1.255  255.255.255.255            On-link       192.168.1.2    276
      192.168.3.0    255.255.255.0            On-link     192.168.3.100    281
    192.168.3.100  255.255.255.255            On-link     192.168.3.100    281
    192.168.3.255  255.255.255.255            On-link     192.168.3.100    281
        224.0.0.0        240.0.0.0            On-link         127.0.0.1    306
        224.0.0.0        240.0.0.0            On-link     192.168.3.100    281
        224.0.0.0        240.0.0.0            On-link       192.168.1.2    276
  255.255.255.255  255.255.255.255            On-link         127.0.0.1    306
  255.255.255.255  255.255.255.255            On-link     192.168.3.100    281
  255.255.255.255  255.255.255.255            On-link       192.168.1.2    276

@pansila
Copy link
Author

pansila commented Jan 22, 2019

Another test.

>>> for i in netifaces.interfaces():
...     if netifaces.AF_INET in netifaces.ifaddresses(i):
...         for address in netifaces.ifaddresses(i)[netifaces.AF_INET]:
...             print(address)
...
{'addr': '192.168.3.100', 'netmask': '255.255.255.0', 'broadcast': '192.168.3.255'}
{'addr': '192.168.0.100', 'netmask': '255.255.255.255', 'broadcast': '192.168.0.255'}
{'addr': '127.0.0.1', 'netmask': '255.0.0.0', 'broadcast': '127.255.255.255'}

If I delete the entry 192.168.0.100, netifaces can't even see the interface 192.168.0.1

route delete 192.168.0.100
>>> for i in netifaces.interfaces():
...     if netifaces.AF_INET in netifaces.ifaddresses(i):
...         for address in netifaces.ifaddresses(i)[netifaces.AF_INET]:
...             print(address)
...
{'addr': '192.168.3.100', 'netmask': '255.255.255.0', 'broadcast': '192.168.3.255'}
{'addr': '127.0.0.1', 'netmask': '255.0.0.0', 'broadcast': '127.255.255.255'}

Meanwhile, I still can ping 192.168.0.1 and 192.168.0.100

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant