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 188.8.131.52 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', ('184.108.40.206', 8888))
tcpdump -i any 'udp port 8888':
10:28:28.957679 IP 192.168.1.104.51159 > 220.127.116.11.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.