Question

I am trying to develop a Java-based solution for VM's that start without knowing what static IP address they should self-select from a list. My idea for the solution was:

  1. Use Zeroconf/avahi to select an IP address for the VM
  2. VM's broadcast their MAC addresses using multicast. Each VM would know the expected number of peer MAC addresses.
  3. Once all VM's had received all other MAC addresses they would sort them alphabetically and select an IP based on the position of their MAC address in the list - IP.1, IP.2, etc.

Please note DHCP is not available in this environment under any circumstances and I am trying to find a workaround to this problem

I would like help resolving this exception. Please let me know if you can help. Thanks!!

java.net.SocketException: No such device
    at java.net.PlainDatagramSocketImpl.join(Native Method)
    at java.net.AbstractPlainDatagramSocketImpl.join(AbstractPlainDatagramSocketImpl.java:178)
    at java.net.MulticastSocket.joinGroup(MulticastSocket.java:319)

Here is the Java code I am using:

InetAddress address = InetAddress.getByName(mIPAddress);
SocketAddress addr = new InetSocketAddress(address, mPort);
MulticastSocket multiSocket = new MulticastSocket(addr);
multiSocket.joinGroup(address);

Here is the output of /sbin/ifconfig:

eth0      Link encap:Ethernet  HWaddr 08:00:27:1D:BB:21  
      inet6 addr: fe80::a00:27ff:fe1d:bb21/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:152 errors:0 dropped:0 overruns:0 frame:0
      TX packets:182 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:35179 (34.3 KiB)  TX bytes:36383 (35.5 KiB)

eth0:avahi Link encap:Ethernet  HWaddr 08:00:27:1D:BB:21  
      inet addr:169.254.4.55  Bcast:169.254.255.255  Mask:255.255.0.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
      inet addr:127.0.0.1  Mask:255.0.0.0
      inet6 addr: ::1/128 Scope:Host
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:2957 errors:0 dropped:0 overruns:0 frame:0
      TX packets:2957 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:4448536 (4.2 MiB)  TX bytes:4448536 (4.2 MiB)

EDIT: Added Routing Table:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
Was it helpful?

Solution

The interface that eventually joins multicast group is decided via the routing table, so you need ether a default route, or a specific route that matches your multicast addresses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top