Host Name - System Identity and Info
Host Name - System Identity and Info
A host name (hostname) is a unique name that identifies a device on the network; together with the domain name it forms the fully qualified domain name (FQDN). This page describes how to configure the host name, domain name, and static name-resolution entries in VyOS. These parameters are fundamental for identifying the device on the network and for the correct operation of network services.
Overview
The host name and domain name are used for:
- Identifying the device on the network
- Building the FQDN (Fully Qualified Domain Name)
- Logging and monitoring
- Integrating with cloud platforms (Yandex Cloud, VK Cloud)
- DNS resolution of local names
- Operation of network services (NTP, SNMP, syslog)
Host Name
Description
The host name is a unique label that identifies the device on the network. In VyOS the host name is used:
- In the command-line prompt (CLI prompt)
- In system logs
- In the SNMP system name
- As part of the FQDN when a domain name is set
RFC 1123 Restrictions
The host name must comply with the RFC 1123 standard:
Length:
- Minimum: 1 character
- Maximum: 63 characters
Allowed characters:
- Latin letters: a-z, A-Z
- Digits: 0-9
- Hyphen: - (only inside the name)
Rules:
- Must start with a letter or digit
- Must end with a letter or digit
- May contain letters, digits, and hyphens in the middle
- Case-insensitive
- Cannot contain dots, underscores, or other special characters
Configuration
Basic Setup
# Set the host name
set system host-name vyos-router
# Apply the configuration
commit
saveExamples of Valid Names
# Short name
set system host-name gateway
# Name with digits
set system host-name router01
# Name with hyphens
set system host-name core-router-01
# Maximum length (63 characters)
set system host-name vyos-production-core-router-datacenter-moscow-rack-12-unit-1Examples of Invalid Names
# ERROR: starts with a hyphen
set system host-name -router
# ERROR: ends with a hyphen
set system host-name router-
# ERROR: contains an underscore
set system host-name vyos_router
# ERROR: contains a dot
set system host-name vyos.router
# ERROR: contains a space
set system host-name "vyos router"
# ERROR: more than 63 characters
set system host-name vyos-production-core-router-datacenter-moscow-rack-12-unit-1-mgmtDefault Value
On first boot, VyOS uses the default host name:
vyos@vyos:~$After the host name is configured, the CLI prompt changes:
# After setting host-name gateway
vyos@gateway:~$Domain Name
Description
The domain name defines the DNS suffix that is appended to incomplete host names to build the FQDN (Fully Qualified Domain Name).
How it works:
- If only a hostname is specified without a domain, it is used as is
- If both a hostname and a domain-name are specified, the FQDN is formed as:
hostname.domain-name - When resolving incomplete names, the domain suffix is added automatically
Configuration
Basic Setup
# Set the domain name
set system domain-name example.com
# Apply the configuration
commit
saveFull hostname + domain Configuration
# Set the host name and domain
set system host-name router01
set system domain-name corp.example.com
# Result: FQDN = router01.corp.example.com
commit
saveUsage Examples
# Corporate network
set system host-name core-router
set system domain-name datacenter.moscow.mycompany.ru
# FQDN: core-router.datacenter.moscow.mycompany.ru# Cloud infrastructure
set system host-name vyos-gw
set system domain-name cloud.internal
# FQDN: vyos-gw.cloud.internalImpact on Name Resolution
When a domain-name is configured, the system automatically appends it to incomplete names:
# With the setting: set system domain-name example.com
# ping server -> DNS query for server.example.com
vyos@router:~$ ping server
# For fully qualified names the suffix is not added
vyos@router:~$ ping server.otherdomain.comStatic Host Mapping
Description
Static host mappings let you create local name-to-IP-address resolution without an external DNS server. This is the equivalent of manually editing the /etc/hosts file, but managed through the VyOS configuration.
Advantages:
- Managed through the VyOS configuration (commit/rollback)
- Automatic generation of
/etc/hostsat boot - Support for multiple aliases per host
- Persistence across reboots
Warning:
Do not edit the /etc/hosts file manually - it is automatically overwritten from the VyOS configuration at system boot.
Configuration
Basic Entry
# Add a static host mapping
set system static-host-mapping host-name server1.example.com inet 192.168.1.10
# Apply the configuration
commit
saveEntry with Aliases
# Primary entry
set system static-host-mapping host-name db-server.corp.local inet 10.0.1.100
# Adding aliases
set system static-host-mapping host-name db-server.corp.local alias database
set system static-host-mapping host-name db-server.corp.local alias db
set system static-host-mapping host-name db-server.corp.local alias mysql-primary
# Result in /etc/hosts:
# 10.0.1.100 db-server.corp.local database db mysql-primaryMultiple Hosts
# Internal servers
set system static-host-mapping host-name web01.local inet 10.0.10.11
set system static-host-mapping host-name web02.local inet 10.0.10.12
set system static-host-mapping host-name db01.local inet 10.0.10.21
set system static-host-mapping host-name cache01.local inet 10.0.10.31
# Aliases for web servers
set system static-host-mapping host-name web01.local alias www1
set system static-host-mapping host-name web02.local alias www2
# Aliases for the database
set system static-host-mapping host-name db01.local alias database
set system static-host-mapping host-name db01.local alias postgres
# Aliases for the cache
set system static-host-mapping host-name cache01.local alias redis
set system static-host-mapping host-name cache01.local alias cacheIPv6 Support
# IPv4 entry
set system static-host-mapping host-name server.example.com inet 192.168.1.10
# IPv6 entry (if supported)
set system static-host-mapping host-name server.example.com inet6 2001:db8::10
# Dual-stack host
set system static-host-mapping host-name webserver.local inet 10.0.1.50
set system static-host-mapping host-name webserver.local inet6 fd00::50
set system static-host-mapping host-name webserver.local alias wwwRemoving Entries
# Remove a specific alias
delete system static-host-mapping host-name server.local alias www
# Remove the entire host entry
delete system static-host-mapping host-name server.local
# Apply the changes
commit
saveCloud Platform Examples
Example 1: Yandex Cloud - Cloud-init vs Static Configuration
In Yandex Cloud the host name can be set via cloud-init when a VM is created. However, to guarantee the name is preserved, it is recommended to use the VyOS configuration.
Scenario: Conflict Between cloud-init and VyOS config
# Situation: cloud-init sets the hostname "instance-1"
# Requirement: override it to "vyos-edge-router"
# Solution: the VyOS configuration takes precedence
configure
set system host-name vyos-edge-router
set system domain-name ru-central1.internal
# Static entries for internal Yandex Cloud services
set system static-host-mapping host-name metadata.yandex inet 169.254.169.254
set system static-host-mapping host-name metadata.yandex alias metadata
# Internal servers in Yandex Cloud
set system static-host-mapping host-name app-server-1.ru-central1.internal inet 10.128.0.10
set system static-host-mapping host-name app-server-2.ru-central1.internal inet 10.128.0.11
set system static-host-mapping host-name db-master.ru-central1.internal inet 10.129.0.5
commit
save
exitVerifying Configuration Precedence
# Check the configured host name
vyos@vyos-edge-router:~$ show host name
vyos-edge-router
# Check the FQDN
vyos@vyos-edge-router:~$ hostname -f
vyos-edge-router.ru-central1.internal
# Check resolution of the metadata server
vyos@vyos-edge-router:~$ ping metadata
PING metadata.yandex (169.254.169.254) 56(84) bytes of data.Post-deployment Script for Yandex Cloud
#!/bin/vbash
# vyos-yandex-cloud-init.sh
# Script for configuring VyOS in Yandex Cloud after deployment
source /opt/vyatta/etc/functions/script-template
configure
# Basic host configuration
set system host-name vyos-router-{{ zone_id }}
set system domain-name {{ folder_name }}.yandex.internal
# Yandex Cloud metadata service
set system static-host-mapping host-name metadata.yandex.cloud inet 169.254.169.254
set system static-host-mapping host-name metadata.yandex.cloud alias metadata
set system static-host-mapping host-name metadata.yandex.cloud alias cloud-init
# Yandex Cloud DNS servers
set system name-server 192.168.0.2
commit
save
exitExample 2: VK Cloud - DNS Resolution with Static Hosts
In VK Cloud you often need to configure local names for internal services when there is no corporate DNS.
Configuration for a VK Cloud Project
configure
# Base configuration
set system host-name vkcloud-gateway
set system domain-name msk1.cloud.vk.com
# Static entries for VK Cloud infrastructure endpoints
set system static-host-mapping host-name infra.mail.ru inet 10.0.0.1
set system static-host-mapping host-name infra.mail.ru alias vk-infra
# Internal project servers
set system static-host-mapping host-name app-frontend.msk1.cloud.vk.com inet 10.0.10.10
set system static-host-mapping host-name app-frontend.msk1.cloud.vk.com alias frontend
set system static-host-mapping host-name app-frontend.msk1.cloud.vk.com alias web
set system static-host-mapping host-name app-backend.msk1.cloud.vk.com inet 10.0.10.20
set system static-host-mapping host-name app-backend.msk1.cloud.vk.com alias backend
set system static-host-mapping host-name app-backend.msk1.cloud.vk.com alias api
set system static-host-mapping host-name db-postgres.msk1.cloud.vk.com inet 10.0.20.5
set system static-host-mapping host-name db-postgres.msk1.cloud.vk.com alias database
set system static-host-mapping host-name db-postgres.msk1.cloud.vk.com alias postgres
set system static-host-mapping host-name db-postgres.msk1.cloud.vk.com alias db
set system static-host-mapping host-name cache-redis.msk1.cloud.vk.com inet 10.0.20.15
set system static-host-mapping host-name cache-redis.msk1.cloud.vk.com alias redis
set system static-host-mapping host-name cache-redis.msk1.cloud.vk.com alias cache
# Monitoring and logging
set system static-host-mapping host-name monitoring.msk1.cloud.vk.com inet 10.0.30.10
set system static-host-mapping host-name monitoring.msk1.cloud.vk.com alias prometheus
set system static-host-mapping host-name monitoring.msk1.cloud.vk.com alias grafana
set system static-host-mapping host-name logging.msk1.cloud.vk.com inet 10.0.30.20
set system static-host-mapping host-name logging.msk1.cloud.vk.com alias syslog
set system static-host-mapping host-name logging.msk1.cloud.vk.com alias logs
commit
save
exitTesting Resolution
# Check resolution by full name
vyos@vkcloud-gateway:~$ ping app-frontend.msk1.cloud.vk.com
PING app-frontend.msk1.cloud.vk.com (10.0.10.10) 56(84) bytes of data.
# Check resolution by alias
vyos@vkcloud-gateway:~$ ping frontend
PING app-frontend.msk1.cloud.vk.com (10.0.10.10) 56(84) bytes of data.
# Check resolution with automatic domain appending
vyos@vkcloud-gateway:~$ ping app-backend
PING app-backend.msk1.cloud.vk.com (10.0.10.20) 56(84) bytes of data.
# Check the contents of /etc/hosts
vyos@vkcloud-gateway:~$ cat /etc/hostsExample 3: Hybrid Configuration with External DNS
configure
# Base configuration
set system host-name border-router
set system domain-name production.internal
# DNS servers (external + local)
set system name-server 8.8.8.8
set system name-server 8.8.4.4
set system name-server 192.168.1.53
# Static entries for critical local services
# (used when DNS is unavailable)
set system static-host-mapping host-name dc1-core.production.internal inet 192.168.1.1
set system static-host-mapping host-name dc1-core.production.internal alias core-switch
set system static-host-mapping host-name dc1-fw.production.internal inet 192.168.1.254
set system static-host-mapping host-name dc1-fw.production.internal alias firewall
set system static-host-mapping host-name ntp-primary.production.internal inet 192.168.1.10
set system static-host-mapping host-name ntp-primary.production.internal alias ntp
set system static-host-mapping host-name dns-primary.production.internal inet 192.168.1.53
set system static-host-mapping host-name dns-primary.production.internal alias dns
commit
save
exitVerification and Monitoring Commands
Checking the Current Configuration
# Show the configured host name
show host name
# Show host information (hostname + domain)
show host
# Show the FQDN
show host fqdn
# Show all static entries
show system static-host-mapping
# Show the system configuration
show configuration systemChecking at the OS Level
# Current host name (short)
hostname
# FQDN
hostname -f
# All host names
hostname -A
# Domain name
hostname -d
# Contents of /etc/hosts
cat /etc/hosts
# Contents of /etc/hostname
cat /etc/hostname
# Resolution via getent
getent hosts server.localTesting DNS Resolution
# Ping by name
ping server.local
# DNS lookup with nslookup
nslookup server.local
# DNS lookup with dig
dig server.local
# DNS lookup with host
host server.local
# Trace the resolution
dig +trace server.localExample Command Output
show host
vyos@router01:~$ show host
Hostname: router01
Domain: corp.example.com
FQDN: router01.corp.example.comshow host name
vyos@router01:~$ show host name
router01show system static-host-mapping
vyos@router01:~$ show system static-host-mapping
host-name inet alias
db-server.local 10.0.1.100 database, db, mysql
web01.local 10.0.10.11 www1
web02.local 10.0.10.12 www2cat /etc/hosts (generated)
vyos@router01:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 router01.corp.example.com router01
# Static host mappings
10.0.1.100 db-server.local database db mysql
10.0.10.11 web01.local www1
10.0.10.12 web02.local www2
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allroutersTroubleshooting
Problem 1: Host Name Is Not Applied After commit
Symptoms:
- The
show host namecommand shows the new name - The CLI prompt has not changed
- The
hostnamecommand shows the old value
Diagnostics:
# Check the configuration
show configuration system host-name
# Check at the OS level
hostname
cat /etc/hostnameSolution:
# Re-save the configuration
configure
commit
save
exit
# Restart the SSH session (reconnect)
# or run
sudo systemctl restart vyos-routerProblem 2: Static Entries Do Not Work
Symptoms:
ping server.localdoes not workcat /etc/hostsdoes not contain the static entries
Diagnostics:
# Check the static entry configuration
show configuration system static-host-mapping
# Check /etc/hosts
cat /etc/hosts
# Check the resolution order
cat /etc/nsswitch.conf | grep hostsSolution:
# Make sure the configuration is applied
configure
show system static-host-mapping
commit
save
exit
# Force regeneration of /etc/hosts
sudo /opt/vyatta/sbin/vyatta-update-hosts.pl
# Check the result
cat /etc/hostsProblem 3: FQDN Is Built Incorrectly
Symptoms:
hostname -freturns an incorrect value- The FQDN does not include the domain name
Diagnostics:
# Check hostname and domain separately
show host name
show configuration system domain-name
# Check at the OS level
hostname -s # short name
hostname -f # FQDN
hostname -d # domainSolution:
configure
# Verify and fix the configuration
set system host-name correct-hostname
set system domain-name correct.domain.com
commit
save
exit
# Check the result
hostname -fProblem 4: Cloud-init Overrides the hostname
Symptoms:
- After a reboot the hostname reverts to the value from cloud-init
- The VyOS configuration is ignored
Diagnostics:
# Check the cloud-init configuration
cat /etc/cloud/cloud.cfg | grep preserve_hostname
# Check the cloud-init logs
cat /var/log/cloud-init.log | grep hostnameSolution:
# Disable hostname management via cloud-init
sudo vi /etc/cloud/cloud.cfg
# Change:
# preserve_hostname: false
# to:
# preserve_hostname: true
# Or give the VyOS configuration precedence
configure
set system host-name my-vyos-router
commit
save
exit
# Reboot to verify
sudo rebootProblem 5: DNS Resolution Ignores static-host-mapping
Symptoms:
ping server.localgoes to DNS instead of the local /etc/hosts- External DNS returns NXDOMAIN
Diagnostics:
# Check the resolution order
cat /etc/nsswitch.conf | grep hosts
# It should be:
# hosts: files dns
# NOT:
# hosts: dns files
# Check /etc/hosts
cat /etc/hosts | grep server.localSolution:
# Make sure the entry exists in the configuration
configure
show system static-host-mapping
commit
save
exit
# If nsswitch.conf is incorrect, this is a VyOS bug
# Temporary workaround:
sudo vi /etc/nsswitch.conf
# Change the hosts line to: hosts: files dns
# Permanent fix - update VyOS or create a post-config scriptBest Practices
1. Naming Hosts
Use descriptive, structured names:
# Good: role-location-number
set system host-name vyos-gw-msk-01
set system host-name vyos-fw-spb-02
set system host-name vyos-edge-kzn-01
# Bad: unclear or too long
set system host-name router
set system host-name x
set system host-name my-super-duper-production-vyos-router-in-moscowUse a consistent scheme:
# Scheme: service-type-zone-id
set system host-name web-frontend-dc1-01
set system host-name db-postgres-dc1-master
set system host-name cache-redis-dc2-012. Domain Names
Use internal domains for private networks:
# Good: .internal, .local, .private, .lan
set system domain-name corp.internal
set system domain-name datacenter.local
set system domain-name cloud.private
# Avoid: public domains for internal networks
# Bad:
set system domain-name example.com # if not actually usedReflect the network structure in domains:
# Hierarchical structure
set system domain-name moscow.datacenter.mycompany.internal
set system domain-name production.cloud.mycompany.ru
set system domain-name dmz.external.mycompany.net3. Static Host Mappings
Document the purpose of entries:
configure
# Infrastructure services - critical services
set system static-host-mapping host-name ntp.internal inet 10.0.0.10
set system static-host-mapping host-name ntp.internal alias time
set system static-host-mapping host-name dns.internal inet 10.0.0.53
set system static-host-mapping host-name dns.internal alias resolver
# Application servers
set system static-host-mapping host-name app01.internal inet 10.0.10.11
set system static-host-mapping host-name app02.internal inet 10.0.10.12
commit
save
exitUse aliases for convenience:
# Full name + short aliases
set system static-host-mapping host-name database-primary.internal inet 10.0.20.5
set system static-host-mapping host-name database-primary.internal alias db
set system static-host-mapping host-name database-primary.internal alias postgres
set system static-host-mapping host-name database-primary.internal alias primary4. Redundancy for Critical Entries
Duplicate DNS in static-host-mapping:
# Critical services should resolve even when DNS is down
set system static-host-mapping host-name ntp-server.internal inet 192.168.1.10
set system static-host-mapping host-name dns-server.internal inet 192.168.1.53
set system static-host-mapping host-name mgmt-gateway.internal inet 192.168.1.1
set system static-host-mapping host-name syslog-server.internal inet 192.168.1.1005. Integration with Cloud Providers
Yandex Cloud:
# Use zonal names
set system host-name vyos-gw-ru-central1-a
set system domain-name ru-central1.internal
# Add the metadata service
set system static-host-mapping host-name metadata.yandex inet 169.254.169.254VK Cloud:
# Use the region in the naming
set system host-name vyos-router-msk1
set system domain-name msk1.cloud.internal
# Add Cloud infrastructure endpoints
set system static-host-mapping host-name infra.mail.ru inet 10.0.0.16. Configuration Versioning
Use commit comments:
configure
set system host-name new-router-name
commit comment "Changed hostname from old-router to new-router-name for standardization"
saveMake backups before changes:
# Save the current configuration
save /config/backup-before-hostname-change.config
# Make the changes
configure
set system host-name new-name
commit
save7. Monitoring and Auditing
Regularly check for consistency:
# Hostname consistency check script
#!/bin/bash
VYOS_HOSTNAME=$(show host name)
OS_HOSTNAME=$(hostname)
if [ "$VYOS_HOSTNAME" != "$OS_HOSTNAME" ]; then
echo "WARNING: Hostname mismatch!"
echo "VyOS config: $VYOS_HOSTNAME"
echo "OS hostname: $OS_HOSTNAME"
fiLog changes:
# View the hostname change history
show system commit
# View a specific commit
show system commit diff <commit-number>Integration with Other VyOS Services
SNMP
The hostname is used as SNMPv2-MIB::sysName:
configure
set system host-name core-router-01
set service snmp community public
commit
save
exit
# An SNMP query will show the hostname
snmpget -v2c -c public localhost SNMPv2-MIB::sysName.0
# Output: SNMPv2-MIB::sysName.0 = STRING: core-router-01Syslog
The hostname is included in syslog messages:
configure
set system host-name vyos-gateway
set system syslog global facility all level info
set system syslog host 10.0.0.100 facility all level warning
commit
save
exit
# Syslog messages will contain the hostname:
# Dec 15 10:30:45 vyos-gateway systemd[1]: Started VyOS Router.NTP
When configuring an NTP server, the hostname is used for identification:
configure
set system host-name ntp-client-router
set system ntp server 0.pool.ntp.org
set system ntp server 1.pool.ntp.org
commit
save
exitSSH Banner
The hostname can be used in the SSH banner:
configure
set system host-name secure-gateway
set system login banner pre-login "
****************************************************
Authorized access only!
Hostname: secure-gateway
Location: Moscow Datacenter
****************************************************
"
commit
save
exitComplete Configuration Examples
Configuration 1: Corporate Gateway
configure
# Hostname and domain
set system host-name corp-gateway-msk
set system domain-name moscow.corp.internal
# Internal servers
set system static-host-mapping host-name dc-controller.moscow.corp.internal inet 10.10.0.10
set system static-host-mapping host-name dc-controller.moscow.corp.internal alias dc
set system static-host-mapping host-name dc-controller.moscow.corp.internal alias ad
set system static-host-mapping host-name exchange.moscow.corp.internal inet 10.10.0.20
set system static-host-mapping host-name exchange.moscow.corp.internal alias mail
set system static-host-mapping host-name fileserver.moscow.corp.internal inet 10.10.0.30
set system static-host-mapping host-name fileserver.moscow.corp.internal alias fs
set system static-host-mapping host-name fileserver.moscow.corp.internal alias files
# Infrastructure
set system static-host-mapping host-name ntp.moscow.corp.internal inet 10.10.0.1
set system static-host-mapping host-name ntp.moscow.core.internal alias time
set system static-host-mapping host-name dns.moscow.corp.internal inet 10.10.0.2
set system static-host-mapping host-name dns.moscow.corp.internal alias resolver
# Monitoring
set system static-host-mapping host-name zabbix.moscow.corp.internal inet 10.10.0.100
set system static-host-mapping host-name zabbix.moscow.corp.internal alias monitoring
commit
save
exitConfiguration 2: Cloud Edge Router (Yandex Cloud)
configure
# Cloud hostname
set system host-name yc-edge-router-01
set system domain-name ru-central1-a.cloud.internal
# Yandex Cloud metadata
set system static-host-mapping host-name metadata.yandex.cloud inet 169.254.169.254
set system static-host-mapping host-name metadata.yandex.cloud alias metadata
set system static-host-mapping host-name metadata.yandex.cloud alias cloud-init
# Application infrastructure in Yandex Cloud
set system static-host-mapping host-name app-lb.ru-central1-a.cloud.internal inet 10.128.0.10
set system static-host-mapping host-name app-lb.ru-central1-a.cloud.internal alias loadbalancer
set system static-host-mapping host-name app-lb.ru-central1-a.cloud.internal alias lb
set system static-host-mapping host-name app-web-01.ru-central1-a.cloud.internal inet 10.128.0.20
set system static-host-mapping host-name app-web-01.ru-central1-a.cloud.internal alias web1
set system static-host-mapping host-name app-web-02.ru-central1-a.cloud.internal inet 10.128.0.21
set system static-host-mapping host-name app-web-02.ru-central1-a.cloud.internal alias web2
set system static-host-mapping host-name db-managed-postgres.ru-central1-a.cloud.internal inet 10.129.0.5
set system static-host-mapping host-name db-managed-postgres.ru-central1-a.cloud.internal alias database
set system static-host-mapping host-name db-managed-postgres.ru-central1-a.cloud.internal alias postgres
# Yandex Cloud DNS (internal)
set system name-server 192.168.0.2
commit
save
exitConfiguration 3: VK Cloud Multi-zone Setup
configure
# VK Cloud hostname
set system host-name vkc-router-msk1-zone-a
set system domain-name msk1.vkcloud.internal
# VK Cloud infrastructure
set system static-host-mapping host-name infra.mail.ru inet 10.0.0.1
set system static-host-mapping host-name infra.mail.ru alias vk-infra
# Zone A servers
set system static-host-mapping host-name web-a1.msk1.vkcloud.internal inet 10.0.10.11
set system static-host-mapping host-name web-a2.msk1.vkcloud.internal inet 10.0.10.12
# Zone B servers (cross-zone communication)
set system static-host-mapping host-name web-b1.msk1.vkcloud.internal inet 10.1.10.11
set system static-host-mapping host-name web-b2.msk1.vkcloud.internal inet 10.1.10.12
# Managed services
set system static-host-mapping host-name db-managed.msk1.vkcloud.internal inet 10.0.20.5
set system static-host-mapping host-name db-managed.msk1.vkcloud.internal alias database
set system static-host-mapping host-name cache-managed.msk1.vkcloud.internal inet 10.0.20.15
set system static-host-mapping host-name cache-managed.msk1.vkcloud.internal alias redis
# Monitoring and Logging
set system static-host-mapping host-name mon.msk1.vkcloud.internal inet 10.0.30.10
set system static-host-mapping host-name mon.msk1.vkcloud.internal alias monitoring
set system static-host-mapping host-name mon.msk1.vkcloud.internal alias prometheus
set system static-host-mapping host-name log.msk1.vkcloud.internal inet 10.0.30.20
set system static-host-mapping host-name log.msk1.vkcloud.internal alias syslog
commit
save
exitAutomation and Scripts
Bulk Host Addition Script
#!/bin/vbash
# add-static-hosts.sh
# Bulk addition of static entries from a CSV file
source /opt/vyatta/etc/functions/script-template
# CSV format: hostname,ip,alias1,alias2,alias3
# Example: web01.local,10.0.10.11,www1,web1,frontend1
HOSTS_FILE="/config/static-hosts.csv"
configure
while IFS=',' read -r hostname ip alias1 alias2 alias3; do
# Skip comments and empty lines
[[ "$hostname" =~ ^#.*$ ]] && continue
[[ -z "$hostname" ]] && continue
echo "Adding host: $hostname -> $ip"
set system static-host-mapping host-name "$hostname" inet "$ip"
if [ -n "$alias1" ]; then
set system static-host-mapping host-name "$hostname" alias "$alias1"
fi
if [ -n "$alias2" ]; then
set system static-host-mapping host-name "$hostname" alias "$alias2"
fi
if [ -n "$alias3" ]; then
set system static-host-mapping host-name "$hostname" alias "$alias3"
fi
done < "$HOSTS_FILE"
commit
save
exit
echo "Static hosts configuration completed!"Consistency Check Script
#!/bin/bash
# check-hostname-consistency.sh
# Check that the hostname matches between the VyOS config and the OS
VYOS_HOSTNAME=$(/opt/vyatta/bin/vyatta-op-cmd-wrapper show host name)
OS_HOSTNAME=$(hostname)
OS_FQDN=$(hostname -f)
echo "=== Hostname Consistency Check ==="
echo "VyOS Config Hostname: $VYOS_HOSTNAME"
echo "OS Hostname: $OS_HOSTNAME"
echo "OS FQDN: $OS_FQDN"
echo ""
if [ "$VYOS_HOSTNAME" = "$OS_HOSTNAME" ]; then
echo "Status: OK - Hostnames match"
exit 0
else
echo "Status: WARNING - Hostname mismatch detected!"
echo "Action required: Restart VyOS router or reconnect SSH session"
exit 1
fiHostname Configuration Export Script
#!/bin/vbash
# export-hostname-config.sh
# Export the hostname configuration in JSON format
source /opt/vyatta/etc/functions/script-template
OUTPUT_FILE="/config/hostname-export.json"
HOSTNAME=$(cli-shell-api showCfg system host-name)
DOMAIN=$(cli-shell-api showCfg system domain-name)
echo "{" > "$OUTPUT_FILE"
echo " \"hostname\": \"$HOSTNAME\"," >> "$OUTPUT_FILE"
echo " \"domain\": \"$DOMAIN\"," >> "$OUTPUT_FILE"
echo " \"fqdn\": \"$HOSTNAME.$DOMAIN\"," >> "$OUTPUT_FILE"
echo " \"static_hosts\": [" >> "$OUTPUT_FILE"
# Get the list of static host mappings
# (requires parsing the output of show configuration)
echo " ]" >> "$OUTPUT_FILE"
echo "}" >> "$OUTPUT_FILE"
echo "Hostname configuration exported to $OUTPUT_FILE"Related Documents
- System Configuration - General system configuration
- Name Server (DNS) - Configuring DNS servers
- NTP - Time and NTP configuration
- Syslog - Configuring system logging
- SNMP - Monitoring via SNMP
- Cloud-init - Automation in the cloud
Additional Resources
- RFC 1123 - Requirements for Internet Hosts
- RFC 952 - DoD Internet Host Table Specification
- VyOS Documentation - System Host Name
- Yandex Cloud Metadata Service
- VK Cloud Documentation
Conclusion
Properly configuring the host name, domain name, and static host mappings is a fundamental part of VyOS configuration. These parameters affect:
- Device identification on the network
- The operation of system services (syslog, SNMP, NTP)
- Integration with cloud platforms
- Manageability and monitoring of the infrastructure
Follow the recommendations in the “Best Practices” section to ensure a consistent and reliable configuration.