java.lang.Object
io.github.astrapi69.net.ip.IpInfoExtensions

public final class IpInfoExtensions extends Object
Utility class for retrieving various types of IP addresses related to the local network and the internet
  • Methodendetails

    • getLocalNetworkIPAddress

      public static String getLocalNetworkIPAddress()
      Gets the local network IP address of this machine by establishing a connection to a public DNS server
      Gibt zurück:
      the local network IP address as a string or an error message if unable to determine
    • getLocalIPAddress

      public static String getLocalIPAddress() throws SocketException
      Gets the local IP address of the machine by iterating through available network interfaces
      Gibt zurück:
      the local IP address as a string or "Not found" if no valid address is available
      Löst aus:
      SocketException - if an error occurs while retrieving network interfaces
    • getRouterIPAddress

      public static String getRouterIPAddress() throws IOException
      Gets the default gateway/router IP address by executing the "ip route" command
      Gibt zurück:
      the router's IP address as a string or "Not found" if unable to retrieve it
      Löst aus:
      IOException - if an error occurs while executing the command
    • getExternalIPAddress

      public static String getExternalIPAddress() throws IOException, URISyntaxException
      Gets the external (public) IP address of the machine by making an HTTP request to an external service
      Gibt zurück:
      the external IP address as a string
      Löst aus:
      IOException - if an error occurs while retrieving the IP address
      URISyntaxException - if an error occurs while the uri is created