Validating ip address in java

So, this method will give the local address that would be used to connect to the specified remote host.There is no real connection established, hence the specified remote ip can be unreachable. The problem is that a host could have lots of network interfaces, and an interface could be bound to more than one IP address.

If the machine has multiple IP addresses, this method will prefer * a site-local IP address (e.g.

Which means your machine is always owning several "local" addresses. Enumeration; /** * Class that allows a device to identify itself on the INTRANET.

Different "local" addresses will be automatically chosen to use when you are connecting to different endpoints. * * @author Decoded4620 2016 */ public class Net Identity Software Loopback Interface 1 -127.0.0.7.0.0.1 - [[email protected] -0:0:0:0:0:0:0:1:0:0:0:0:0:0:0:1 - [[email protected] Broadcom 802.11ac Network Adapter -VIKING.yourisp.com:192.168.1.142 - [[email protected] -fe80:0:0:fa:31d:21ccd%wlan0:fe80:0:0:fa:31d:21ccd%wlan0 - [[email protected] Microsoft Kernel Debug Network Adapter Intel Edison USB RNDIS Device Driver for user-mode network applications Cisco Systems VPN Adapter for 64-bit Windows Virtual Box Host-Only Ethernet Adapter -VIKING:192.168.56.1 - [[email protected] -VIKING:fe80:0:0:0:d599:3cf62:cb7%eth4 - [[email protected] Log Me In Hamachi Virtual Ethernet Adapter -VIKING:25.113.118.39 - [[email protected] -VIKING:2620:9b:0:0:0:27 - [[email protected] -VIKING:fe80:0:0:bf:994d:4686%eth5 - [[email protected] Bluetooth Device (Personal Area Network) -fe80:0:0:0:4c09:2bca:e16b%eth6:fe80:0:0:0:4c09:2bca:e16b%eth6 - [[email protected] Bluetooth Device (RFCOMM Protocol TDI) Intel(R) Ethernet Connection (2) I218-V -fe80:0:0:93:d16c:7c7c%eth7:fe80:0:0:93:d16c:7c7c%eth7 - [[email protected] Microsoft Wi-Fi Direct Virtual Adapter -fe80:0:0:3e:cdf0:c0ac:1751%wlan1:fe80:0:0:3e:cdf0:c0ac:1751%wlan1 - [[email protected] Virtual Box Host-Only Ethernet Adapter-HHD Software NDIS 6.0 Filter Driver-0000 Virtual Box Host-Only Ethernet Adapter-WFP Native MAC Layer Light Weight Filter-0000 Virtual Box Host-Only Ethernet Adapter-HHD Software NDIS 6.0 Filter Driver-0001 Virtual Box Host-Only Ethernet Adapter-HHD Software NDIS 6.0 Filter Driver-0002 Virtual Box Host-Only Ethernet Adapter-Virtual Box NDIS Light-Weight Filter-0000 Virtual Box Host-Only Ethernet Adapter-HHD Software NDIS 6.0 Filter Driver-0003 Virtual Box Host-Only Ethernet Adapter-Qo S Packet Scheduler-0000 Virtual Box Host-Only Ethernet Adapter-HHD Software NDIS 6.0 Filter Driver-0004 Virtual Box Host-Only Ethernet Adapter-WFP 802.3 MAC Layer Light Weight Filter-0000 Virtual Box Host-Only Ethernet Adapter-HHD Software NDIS 6.0 Filter Driver-0005 Intel(R) Ethernet Connection (2) I218-V-HHD Software NDIS 6.0 Filter Driver-0000 Intel(R) Ethernet Connection (2) I218-V-WFP Native MAC Layer Light Weight Filter-0000 Intel(R) Ethernet Connection (2) I218-V-HHD Software NDIS 6.0 Filter Driver-0001 Intel(R) Ethernet Connection (2) I218-V-Shrew Soft Lightweight Filter-0000 Intel(R) Ethernet Connection (2) I218-V-HHD Software NDIS 6.0 Filter Driver-0002 Intel(R) Ethernet Connection (2) I218-V-Virtual Box NDIS Light-Weight Filter-0000 Intel(R) Ethernet Connection (2) I218-V-HHD Software NDIS 6.0 Filter Driver-0003 Intel(R) Ethernet Connection (2) I218-V-Qo S Packet Scheduler-0000 Intel(R) Ethernet Connection (2) I218-V-HHD Software NDIS 6.0 Filter Driver-0004 Intel(R) Ethernet Connection (2) I218-V-WFP 802.3 MAC Layer Light Weight Filter-0000 Intel(R) Ethernet Connection (2) I218-V-HHD Software NDIS 6.0 Filter Driver-0005 Broadcom 802.11ac Network Adapter-WFP Native MAC Layer Light Weight Filter-0000 Broadcom 802.11ac Network Adapter-Virtual Wi Fi Filter Driver-0000 Broadcom 802.11ac Network Adapter-Native Wi Fi Filter Driver-0000 Broadcom 802.11ac Network Adapter-HHD Software NDIS 6.0 Filter Driver-0003 Broadcom 802.11ac Network Adapter-Shrew Soft Lightweight Filter-0000 Broadcom 802.11ac Network Adapter-HHD Software NDIS 6.0 Filter Driver-0004 Broadcom 802.11ac Network Adapter-Virtual Box NDIS Light-Weight Filter-0000 Broadcom 802.11ac Network Adapter-HHD Software NDIS 6.0 Filter Driver-0005 Broadcom 802.11ac Network Adapter-Qo S Packet Scheduler-0000 Broadcom 802.11ac Network Adapter-HHD Software NDIS 6.0 Filter Driver-0006 Broadcom 802.11ac Network Adapter-WFP 802.3 MAC Layer Light Weight Filter-0000 Broadcom 802.11ac Network Adapter-HHD Software NDIS 6.0 Filter Driver-0007 Microsoft Wi-Fi Direct Virtual Adapter-WFP Native MAC Layer Light Weight Filter-0000 Microsoft Wi-Fi Direct Virtual Adapter-Native Wi Fi Filter Driver-0000 Microsoft Wi-Fi Direct Virtual Adapter-HHD Software NDIS 6.0 Filter Driver-0002 Microsoft Wi-Fi Direct Virtual Adapter-Shrew Soft Lightweight Filter-0000 Microsoft Wi-Fi Direct Virtual Adapter-HHD Software NDIS 6.0 Filter Driver-0003 Microsoft Wi-Fi Direct Virtual Adapter-Virtual Box NDIS Light-Weight Filter-0000 Microsoft Wi-Fi Direct Virtual Adapter-HHD Software NDIS 6.0 Filter Driver-0004 Microsoft Wi-Fi Direct Virtual Adapter-Qo S Packet Scheduler-0000 Microsoft Wi-Fi Direct Virtual Adapter-HHD Software NDIS 6.0 Filter Driver-0005 Microsoft Wi-Fi Direct Virtual Adapter-WFP 802.3 MAC Layer Light Weight Filter-0000 Microsoft Wi-Fi Direct Virtual Adapter-HHD Software NDIS 6.0 Filter Driver-0006 For my use I'm setting up a Upnp Server, it helped to understand the 'pattern' that i was looking for. |2[0-4]\d|25[0-5])$"); public static boolean validate(final String ip) Thank you for your interest in this question.

192.168.x.x or 10.10.x.x, usually IPv4) if the machine has one (and will return the * first site-local address if the machine has more than one), but if the machine does not hold a site-local * address, this method will return simply the first non-loopback address found (IPv4 or IPv6).

* When you are looking for your "local" address, you should note that each machine has not only a single network interface, and each interface could has its own local address.

Leave a Reply