Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

header-navigation
keyboard_arrow_up
list Table of Contents
file_download PDF
{ "lLangCode": "en", "lName": "English", "lCountryCode": "us", "transcode": "en_US" }
English
keyboard_arrow_right

Hostnames

date_range 28-Sep-24

Configure the Hostname of a Device in a Configuration Group

The hostname of a device running Junos OS device is its identification. A network device must have its identity established to be accessible on the network. That is perhaps the most important reason to have a hostname, but a hostname also has other purposes.

Junos OS uses the configured hostname as part of the command prompt and to prepend log files and other accounting information. The hostname is also used anywhere else where knowing the device identity is important. For these reasons, we recommend that you provide hostnames that are descriptive and memorable.

You can configure the hostname at the [edit system] hierarchy level. Optionally, instead of configuring the hostname at the [edit system] hierarchy level, you can use a configuration group, as shown in this procedure. This is a recommended best practice for configuring the hostname, especially if the device has dual Routing Engines. This procedure uses groups called re0 and re1 as an example.

Note:

If you configure hostnames that are longer than the CLI screen width, regardless of the terminal screen width setting, the commit operation occurs successfully. Even if the terminal screen width is less than the hostname length, the commit is successful.

To set the hostname by using a configuration group:

  1. Include the host-name statement at the [edit groups group-name system] hierarchy level.

    The hostname value must be less than 256 characters.

    content_copy zoom_out_map
    [edit groups group-name system]
    host-name hostname;
    

    For example:

    content_copy zoom_out_map
    [edit groups re0 system]
    root@# set host-name san-jose-router0
    
    content_copy zoom_out_map
    [edit groups re1 system]
    root@# set host-name san-jose-router1
    
  2. If you used one or more configuration groups, apply the configuration groups, substituting the appropriate group names.

    For example:

    content_copy zoom_out_map
    [edit]
    user@host# set apply-groups [re0 re1]
    
  3. Commit the changes.
    content_copy zoom_out_map
    [edit]
    root@# commit
    

    The hostname appears in the device CLI prompt.

    content_copy zoom_out_map
    san-jose-router0# 
    

Mapping the Hostname of the Switch to IP Addresses

To map a hostname of a switch to one or more IP addresses, include the inet statement at the [edit system static-host-mapping hostname] hierarchy level:

content_copy zoom_out_map
[edit system]
static-host-mapping {
    hostname {
        inet [ addresses ];
        alias [ aliases ];
    }
}

hostname is the name specified by the host-name statement at the [edit system] hierarchy level.

For each host, you can specify one or more aliases.

Example: Configuring the Name of the Switch, IP Address, and System ID

The following example shows how to configure the switch name, map the name to an IP address and alias, and configure a system identifier:

content_copy zoom_out_map
[edit]
user@switch# set system host-name switch1
[edit]
user@switch# set system static-host-mapping switch1 inet 192.168.1.77
[edit]
user@switch# set system static-host-mapping switch1 alias sj1
[edit]
user@switch# set system static-host-mapping switch1 sysid 1921.6800.1077
[edit]
user@switch# show
system {
    host-name switch-sj1;
    static-host-mapping {
        switch-sj1 {
            inet 192.168.1.77;
            alias sj1;
            sysid 1921.6800.1077;
        }
    }
}
footer-navigation