iControl 101 - #10 - System Inet

The little-known System Inet interface is used to access internal API functionality that you can use to test name resolutions as well as service mappings and time settings.  This article will discuss the methods in and illustrate some example usages of the System Inet interface.

Setup

This article will use the PowerShell snapin for iControl as the iControl client.  The following setup is required to run these examples:

PS> Add-PSSnapIn iControlSnapIn
PS> Initialize-F5.iControl -Hostname bigip_address -Username bigip_username, -Password -bigip_passwor
PS> $ic = Get-F5.iControl

Internal DNS Servers

You can query the DSN Server Address that the BIG-IP uses for internal name resolutions with the get_dns_server_address() method.  The method takes no parameters and returns a string array with each nameserver that is defined in the system /etc/resolve.conf file.  At this point there is no way to set the dns server addresses from the System Inet interface.

$ic.SystemInet.get_dns_server_address()
172.27.1.1
172.27.2.1

Time Servers

The /etc/ntp.conf file defines location of time servers for use with local clock synchronization on the BIG-IP.  The get_ntp_server_address() and set_ntp_server_address() methods retrieve and set the list of time servers respectively.  the get_ntp_server_address() method takes no parameters and returns the list of defined time servers.  The set_ntp_server_address() takes as input a list of time servers and updates the /etc/ntp.conf file with those values.

# Get the ntp server on a default setup.  null implies the local clock.
PS > $ic.SystemInet.get_ntp_server_address()
<null>
# Set the ntp server to "time.company.com"
PS > $ic.SystemInet.set_ntp_server_address((,"time.company.com"))
# Check to see if the value was applied
PS > $ic.SystemInet.get_ntp_server_address()
time.company.com
# Set the ntp server back to the local clock by passing in an empty string.
PS > $ic.SystemInet.set_ntp_server_address((,""))
PS > $ic.SystemInet.get_ntp_server_address()
<null>

Hostnames

The get_hostname() method will return the defined hostname of the BIG-IP.  The hostname_to_ip() and ip_to_hostname() methods will attempt to make name resolutions with the local dns server.  The hostname_to_ip() method takes as input a hostname string and returns the ip address if it can be resolved, otherwise an exception is thrown.  The ip_to_hostname() does the opposite in that it will take an ip address and return a list of resolved hostnames.

# Query the hostname of the BIG-IP
PS > $ic.SystemInet.get_hostname()
theboss.dev.net
# Attempt to resolve valid hostname "yoda"
PS > $ic.SystemInet.hostname_to_ip((,"yoda"))
172.27.230.160
# Attempt to resolve invalid hostname "foo"
PS > $ic.SystemInet.hostname_to_ip((,"foo"))
Exception calling "hostname_to_ip" with "1" argument(s): "Exception caught in System::Inet::hostname_to_ip()
Exception: Common::OperationFailed
    primary_error_code   : 16908368 (0x01020050)
    secondary_error_code : 0
    error_string         : 01020050:3: The requested host name (foo) cannot be resolved to an IP address."
At line:1 char:30
+ $ic.SystemInet.hostname_to_ip( <<<< (,"foo"))
# Reverse Resolve valid address 172.27.230.160
$ic.SystemInet.ip_to_hostname((,"172.27.230.160"))
yoda.pdsea.f5net.com
# Reverse Resolve invalid address 10.10.10.10
$ic.SystemInet.ip_to_hostname((,"10.10.10.10"))
10.10.10.10

System Services

System services port assignments are defined in the /etc/services file on the BIG-IP.  The service_name_to_service_number() method will convert a list of service names (ie. http, https) to their respective service number (ie. 80, 443) and the service_number_to_service_name() method perform the inverse, taking a list of service numbers and converting them to their respective service names.

# Query a the service numbers for http and https
PS > $ic.SystemInet.service_name_to_service_number(("http", "https"))
80
443
# Query the service names for service numbers 80 and 443
PS > $ic.SystemInet.service_number_to_service_name((80, 443))
http
https
# Query the service names for service numbers 1 through 10
PS > $ic.SystemInet.service_number_to_service_name((1..10))
tcpmux
nbp
3
echo
rje
zip
echo
8
discard
10

Conclusion

If you need to determine how the BIG-IP is resolving names to addresses or service name mappings, the System Inet interface is the place to look.  The above examples used PowerShell as a client, but usage for other langauges such as .Net, Java, and Perl are similar in nature.

Get the Flash Player to see this player.
Published Apr 10, 2008
Version 1.0

Was this article helpful?

No CommentsBe the first to comment