Details
-
Improvement
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
1.0.2
-
None
-
Mac os x, a bunch of network interfaces: eth0, wlan0, vnic0, vnic1, tun0, lo
Description
I noticed this inconvenience when I ran spark-shell with my virtual machines on and VPN service running.
There are a lot of network interfaces on my laptop(inactive devices omitted):
lo0: inet 127.0.0.1
en1: inet 192.168.0.102
vnic0: inet 10.211.55.2 (virtual if for vm1)
vnic1: inet 10.37.129.3 (virtual if for vm2)
tun0: inet 172.16.100.191 --> 172.16.100.191 (tun device for VPN)
In spark core, Utils.findLocalIpAddress() uses NetworkInterface.getNetworkInterfaces to get all active network interfaces, but unfortunately, this method returns network interfaces in reverse order compared to the ifconfig output (both use ioctl sys call). I dug into the openJDK 6 and 7 source code and confirms this behavior(It just happens on unix-like system, windows deals with it and returns in index order). So, the findLocalIpAddress method will pick the ip address associated with tun0 rather than en1