4

I'm running Windows 10. I had recently diagnosed an issue with my computer where any packet sent to a multicast destination is sent through the loopback interface rather than the 'default' one (see my adventures here).

Example code:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(b"herpyderp", ('224.0.0.251', 5353))

The packet is seen on the loopback interface only (used Microsoft Message Analyzer to sniff).

I tried inspecting the routing table via route print, and got the following output:

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      10.0.10.138       10.0.10.30     35
        10.0.10.0    255.255.255.0         On-link        10.0.10.30    291
       10.0.10.30  255.255.255.255         On-link        10.0.10.30    291
      10.0.10.255  255.255.255.255         On-link        10.0.10.30    291
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link        10.0.10.30    291
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link        10.0.10.30    291
===========================================================================

You'll note the metric indicates the packet should be sent through my 'default' interface.

I then tried inspecting the interface metric via the PowerShell Get-NetIPInterface cmdlet (as implied here), and got the following output:

ifIndex InterfaceAlias                  AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp     ConnectionState PolicyStore
------- --------------                  ------------- ------------ --------------- ----     --------------- -----------
2       Ethernet 3                      IPv6                  1500              35 Enabled  Connected       ActiveStore
7       Ethernet                        IPv6                  1500               5 Enabled  Disconnected    ActiveStore
1       Loopback Pseudo-Interface 1     IPv6            4294967295              75 Disabled Connected       ActiveStore
3       isatap.home                     IPv6                  1280              75 Disabled Disconnected    ActiveStore
17      Teredo Tunneling Pseudo-Inte... IPv6                  1280              75 Enabled  Connected       ActiveStore
2       Ethernet 3                      IPv4                  1500              35 Enabled  Connected       ActiveStore
7       Ethernet                        IPv4                  1500               5 Enabled  Disconnected    ActiveStore
1       Loopback Pseudo-Interface 1     IPv4            4294967295              75 Disabled Connected       ActiveStore

You'll note the InterfaceMetric field also seems to indicate my packet should be sent through the 'default' interface rather than through the loopback interface.

Forcing the socket to send the packet through a different interface via s.setsockopt(socket.IP_MULTICAST_IF, ...) works, but I shouldn't need to do that.

You'll note that there are two Ethernet interfaces corresponding to two network cards on my motherboard. When I connected the cable to Ethernet instead of Ethernet 3, the code above started behaving as I expected and the packet was sent through that interface rather than through the loopback interface.

What is going on?

DoomMuffins
  • 1,174
  • 1
  • 9
  • 19

2 Answers2

0

On my Win10 PC there is a rule in the firewall: UDP port 5353 (mDNS) is allowed to be used by svchost.exe only. This basically means only some Windows services can use mDNS. You may want to check your own firewall and modify that rule - if you have it.

u354356007
  • 3,205
  • 15
  • 25
  • Disabling the firewall did not help. It is not a firewall issue, because the packet is indeed sent - it's just sent through the loopback interface. – DoomMuffins Oct 19 '16 at 14:47
0

I'm using C++ rather than python, but this helped:

flag = 0;
setsockopt(this->socket, IPPROTO_IP, IP_MULTICAST_LOOP, (char*) & flag,sizeof(flag))

Disableing IP_MULTICAST_LOOP helped!

Ken
  • 1