Package io.github.astrapi69.net.ip
Klasse IpInfoExtensions
java.lang.Object
io.github.astrapi69.net.ip.IpInfoExtensions
Utility class for retrieving various types of IP addresses related to the local network and the
internet
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic String
Gets the external (public) IP address of the machine by making an HTTP request to an external servicestatic String
Gets the local IP address of the machine by iterating through available network interfacesstatic String
Gets the local network IP address of this machine by establishing a connection to a public DNS serverstatic String
Gets the default gateway/router IP address by executing the "ip route" command
-
Methodendetails
-
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
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
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
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 addressURISyntaxException
- if an error occurs while the uri is created
-