Take the 2-minute tour ×

I have a windows XP machine having a single network adapter with 2 IP addresses (basically there are 2 subnets on the same physical network):

IP Address 1: mask

IP address 2: mask

Default Gateway:

My application which is written in java needs to communicate with other applications using IP multicast on say IP However, this does not work as sound as I add the second IP address to the network adapter. I have done some digging with good old Wireshark and come to the conclusion that the IGMP join request is the problem. The source IP on the datagram is in the case where it works and when it does not. The gateway which is a router seem to ignore the join if the source is not on the same subnet as it itself is configured to be on. You could say that is somewhat fine (although the IGMP spec is a bit silent here), but I cannot see any way to actually influence the source IP of the datagram in any of the many socket APIs I have looked at so far. Everything seems to occur on the network interface with no regards to the actual subnet used.

Also strangely it seems that the source IP on the datagram is actually chosen to be the highest IP number which I guess is predictable but not exactly intuitive. So here are my questions:

  • Is there any way in Java or any of the native windows libraries to set the source IP on the UDP datagram of the IGMP request?
  • Is the fact that the gateway ignores the join because it does not recognise the source the correct behavior (I am going with de facto behavior as the spec is vague on this point)?
share|improve this question
add comment

1 Answer

About a way to actually influence the source IP of the datagram:

SocketOptions.setOption(IP_MULTICAST_IF, InetAddress);



share|improve this answer
add comment

Your Answer


