Skip to content
Advertisement

Tag: network-interface

How would I get only IPv4 addresses

I have the following code which is supposed to get only the IPv4 addresses of all active interfaces, but it still returns an IPv6 address on some computers. I’ve tried to specify using only IPv4 by using System.setProperty(“java.net.preferIPv4Stack” , “true”);, but this only causes getIpAddress() to return an empty list. How should I be getting the IPv4 of active interfaces

Advertisement