-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function get_working_if() returns the wrong default working interface in win10 #2245
Comments
Could you share the content of |
The function Does that behavior cause troubles in one of your use cases? |
Thanks for reply. My routes are as below and I just delete the GUIDs. >>> conf.route.routes
[(0,
0,
'25.255.255.254',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
10034),
(0,
0,
'10.11.91.254',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
25),
(168516352,
4294967040,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(168516513,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(168516607,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(2130706432,
4278190080,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2130706433,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2147483647,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2851995648,
4294901760,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2852031514,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2852061183,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2887516160,
4294901760,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(2887524710,
4294967295,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(2887581695,
4294967295,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(3232239360,
4294967040,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3232239361,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3232239615,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3232291840,
4294967040,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3232291841,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3232292095,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [SVN Adapter V1.0] {}>,
'169.254.112.118',
311),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [TAP-Windows Adapter V9] {}>,
'169.254.26.68',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Bluetooth Device (Personal Area Network) #2] {}>,
'169.254.227.190',
321),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Intel(R) Dual Band Wireless-AC 8265 #2] {}>,
'169.254.62.191',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #3] {}>,
'169.254.173.211',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #4] {}>,
'169.254.192.230',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [SVN Adapter V1.0] {}>,
'169.254.112.118',
311),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [TAP-Windows Adapter V9] {}>,
'169.254.26.68',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Bluetooth Device (Personal Area Network) #2] {}>,
'169.254.227.190',
321),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Dual Band Wireless-AC 8265 #2] {}>,
'169.254.62.191',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #3] {}>,
'169.254.173.211',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #4] {}>,
'169.254.192.230',
281)] |
Yeah I need a function/variable to return the default interface. So how can I get the correct one especially when the network has been changed? |
You forgot the final “s” while typing the command. Can you try again and share the result (a Python list) ?
|
OK so you have two issues there:
For the first, you need to run For the second, |
Yeah. The new result is as below. >>> conf.route.routes
[(0,
0,
'25.255.255.254',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
10034),
(0,
0,
'10.11.91.254',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
25),
(168516352,
4294967040,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(168516513,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(168516607,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(2130706432,
4278190080,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2130706433,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2147483647,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2851995648,
4294901760,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2852031514,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2852061183,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(2887516160,
4294901760,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(2887524710,
4294967295,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(2887581695,
4294967295,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(3232239360,
4294967040,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3232239361,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3232239615,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3232291840,
4294967040,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3232291841,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3232292095,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [SVN Adapter V1.0] {}>,
'169.254.112.118',
311),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [TAP-Windows Adapter V9] {}>,
'169.254.26.68',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Bluetooth Device (Personal Area Network) #2] {}>,
'169.254.227.190',
321),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Intel(R) Dual Band Wireless-AC 8265 #2] {}>,
'169.254.62.191',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #3] {}>,
'169.254.173.211',
281),
(3758096384,
4278190080,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #4] {}>,
'169.254.192.230',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [SVN Adapter V1.0] {}>,
'169.254.112.118',
311),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet1] {}>,
'192.168.220.1',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [TAP-Windows Adapter V9] {}>,
'169.254.26.68',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [VMware Virtual Ethernet Adapter for VMnet8] {}>,
'192.168.15.1',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Ethernet Connection (5) I219-V #2] {}>,
'10.11.91.161',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Npcap Loopback Adapter] {}>,
'127.0.0.1',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Bluetooth Device (Personal Area Network) #2] {}>,
'169.254.227.190',
321),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Intel(R) Dual Band Wireless-AC 8265 #2] {}>,
'169.254.62.191',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [ZeroTier One Virtual Port] {}>,
'172.28.33.102',
291),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #3] {}>,
'169.254.173.211',
281),
(4294967295,
4294967295,
'0.0.0.0',
<NetworkInterface [Microsoft Wi-Fi Direct Virtual Adapter #4] {}>,
'169.254.192.230',
281)] |
Thanks for reply. It seems to get the right interface by using |
The return value of |
Environment :Win10, python 3.7 and scapy 2.4.3
My route is as below. The ZeroTier is a virtual internal interface and the I219 is my real external interface that connects the Internet. According to the Metric, the I219 is the default working iface and conf.iface returns right meanwhile get_working_if() returns the ZeroTier.
Maybe the reason is that get_working_if() returns the interface associated with the route with smallest mask but not the smallest metric accroding to the file /Lib/site-packages/scapy/arch/windows/__init__.py
Does anyone else have the same problem?
The text was updated successfully, but these errors were encountered: