nadzoring.network_base.router_ip module¶
Returns the default router(gateway) ip address on Linux and Windows machines.
On some Linux machines, it requires the net-tools package to be installed, as the route command does not work without it (example: Ubuntu):
$ sudo apt install net-tools
- nadzoring.network_base.router_ip.check_ipv4(hostname: str) str[source]¶
Checking whether the received value is an ip address.
If the received value is not an ip address, an exception is thrown and the received value is passed to the function to obtain the address from the domain name. If the check is successful, the address is returned from the function.
- Parameters:
hostname (str) – hostname address
- Returns:
hostname
- Return type:
str
- nadzoring.network_base.router_ip.check_ipv6(hostname: str) str[source]¶
Checking whether the received value is an ip address.
If the received value is not an ip address, an exception is thrown and the received value is passed to the function to obtain the address from the domain name. If the check is successful, the address is returned from the function.
- Parameters:
hostname (str) – hostname address
- Returns:
hostname
- Return type:
str
- nadzoring.network_base.router_ip.get_ip_from_host(hostname: str) str[source]¶
Attempts to retrieve an IP address from a domain name.
If unsuccessful, returns the value passed to the function.
- Parameters:
hostname (str) – hostname address
- Returns:
host
- Return type:
str
- nadzoring.network_base.router_ip.router_ip(*, ipv6: bool = False) str | None[source]¶
The OS version is determined, then determine the router address.
Then the received value is sent to check if it matches the address. If the received address is IPv4, it is returned from the function. If the address is a domain name, and there may be such cases, the received name is passed to the function where the attempt is performed. getting an ip address by domain name. For example, if the system uses pfsence.
- Parameters:
ipv6 (bool, optional) – use IPv6 instead of IPv4. Defaults to False.
- Returns:
ip route result or None
- Return type:
str | None