Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
Automation Scripting User Guide
Table of Contents Expand all
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

hostname() Function (Python, SLAX, and XSLT)

date_range 30-May-23

Namespaces

content_copy zoom_out_map
http://xml.juniper.net/junos/commit-scripts/1.0

Python Syntax

content_copy zoom_out_map
name = jcs.hostname(address)

SLAX Syntax

content_copy zoom_out_map
var $name = jcs:hostname(address);

XSLT Syntax

content_copy zoom_out_map
<xsl:variable name="name" select="jcs:hostname(address)"/>

Description

Return the fully qualified domain name associated with a given IPv4 or IPv6 address. The DNS server must be configured on the device in order to resolve the domain name.

Parameters

address

String containing an IPv4 or IPv6 address.

Return Value

name

Hostname associated with the IP address.

Usage Examples

The following SLAX example initializes the variable address with the IP address 198.51.100.1. The $address variable is passed as the argument to the jcs:hostname() function. If the DNS server is configured on the device, the function will resolve the IP address and return the fully qualified domain name, which is stored in the variable host.

content_copy zoom_out_map
var $address = "198.51.100.1";
var $host = jcs:hostname($address);

In XSLT:

content_copy zoom_out_map
<xsl:variable name="address" select="198.51.100.1">
<xsl:variable name="host" select="jcs:hostname($address)"/>

In Python:

content_copy zoom_out_map
host = jcs.hostname("198.51.100.1")

Release Information

Function introduced in Junos OS Release 7.6.

Support for SLAX syntax added in Junos OS Release 8.2.

Support for Python added in Junos OS Release 16.1R1.

footer-navigation