Q: Linux ignoring multicast route over loopback I'm trying to test some multicast code on a single machine. I'm trying to get the packets sent over the loopback device (lo) instead of the default eth1. Googling keeps turning up the incantation
route add -net 224.0.0.0 netmask 240.0.0.0 dev lo
ifconfig lo multicast

but even after doing this the packets are still going out over eth1. Sample code (Python)
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b'hello world', ('225.100.101.0', 8888))

Output from tcpdump -i any 'udp port 8888':
10:28:28.957679 IP 192.168.1.104.51159 > 225.100.101.0.8888: UDP, length 11

where 192.168.1.104 is the host address for eth1. I know I can use the IP_MULTICAST_IF socket option to force it (and this does work), but I'd prefer to be able to set routing policy once on the machine rather than in every application that does multicast.
I'm running Ubuntu 14.04 with kernel 3.13.0-68-generic.

A: It turns out that looking at IP addresses in tcpdump was misleading: it always seems to use 192.168.1.104 as the source address, even when sending the packet over loopback. When specifying an interface to tcpdump I could tell which interface was actually used. The route was indeed working some of the time. This question describes a case where it doesn't work.
