How do you get a socket to receive packets destined for the IPv6 Subnet-Routers Anycast address?
I haven’t been able to find any informationn on how to do this.
In a fit of desparation, I’ve tried using socket.setsockopt as you would to join a multicast group:
# 7 is the interface number s = socket(AF_INET6, SOCK_DGRAM) packed_iface_num = struct.pack('I', 7) group = inet_pton(AF_INET6, 'fd36:d00d:d00d:47cb::') + packed_iface_num # socket.error: (22, 'Invalid argument') s.setsockopt(IPPROTO_IPV6, IPV6_JOIN_GROUP, group)
And also using bind
# socket.error: (99, 'Cannot assign requested address') s.bind(('fd36:773e:6b4c:47cb::', 9876))
As expected, neither of these worked. Is there a way to do this?
Instead of
IPV6_JOIN_GROUP, try passingIPV6_JOIN_ANYCASTto yours.setsockopt()code. Unfortunately the Pythonsocketmodule doesn’t define it but you should be able to pass the integer equivalent instead. In LinuxIPV6_JOIN_ANYCASTis27andIPV6_LEAVE_ANYCASTis28. (defined in /usr/include/linux/in6.h)The best documentation I could find is from this lkml e-mail describing the anycast patch to the Linux kernel:
May the dancing kame be with you!