How to Connect to Your VDS Server via SSH (Complete Guide)
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Set hostname with hostnamectl, configure /etc/hosts and /etc/resolv.conf, set up FQDN, understand PTR record importance, and test with dig/nslookup.
Your server's hostname and DNS configuration form the foundation of network communication. A misconfigured hostname can cause email delivery issues, confusion in log records, and some applications to malfunction. This guide covers hostname setup, DNS configuration, and verification steps.
A hostname is the name that identifies your server on the network. There are two types:
webserver01)webserver01.rexe.tr)The FQDN combines the hostname with the domain name and uniquely identifies your server on the internet.
Always use FQDN on production servers. This is critical for mail servers, SSL certificates, and log management.
# Short hostname
hostname
# FQDN
hostname -f
# All hostname information
hostnamectl
# Example output:
# Static hostname: webserver01
# Icon name: computer-server
# Chassis: server
# Operating System: Ubuntu 22.04.3 LTS
# Kernel: Linux 5.15.0-91-generic
# Architecture: x86-64
hostnamectl is the modern tool for hostname management on systemd-based systems.
# Set hostname
sudo hostnamectl set-hostname webserver01
# Set hostname with FQDN
sudo hostnamectl set-hostname webserver01.rexe.tr
# Verify the change
hostnamectl
# Apply change by opening a new shell
exec bash
# Static hostname (persistent, written to /etc/hostname)
sudo hostnamectl set-hostname webserver01 --static
# Transient hostname (reset on reboot)
sudo hostnamectl set-hostname webserver01 --transient
# Pretty hostname (for display purposes)
sudo hostnamectl set-hostname "Web Server 01" --pretty
The hostname is stored persistently in /etc/hostname:
# View the file
cat /etc/hostname
# Edit manually
sudo nano /etc/hostname
webserver01
Write only the short hostname in /etc/hostname, not the FQDN. FQDN configuration is done in /etc/hosts.
The /etc/hosts file is a local name resolution table checked before DNS queries.
# View the file
cat /etc/hosts
# Edit
sudo nano /etc/hosts
127.0.0.1 localhost
127.0.1.1 webserver01.rexe.tr webserver01
# Server's real IP address
203.0.113.100 webserver01.rexe.tr webserver01
# IPv6
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
The 127.0.1.1 line is used for FQDN on Ubuntu/Debian systems. On CentOS/RHEL systems, use the real IP address.
# Local development environment
192.168.1.10 db.local database
192.168.1.20 cache.local redis
# Block a specific domain
0.0.0.0 ads.example.com
# Alias for quick access
10.0.0.5 prod-db production-database
/etc/resolv.conf defines the system's DNS servers.
# View current DNS configuration
cat /etc/resolv.conf
# DNS servers
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 1.1.1.1
# Search domain (for short names)
search rexe.tr
# Domain
domain rexe.tr
# Maximum DNS retry count
options attempts:3
# DNS timeout (seconds)
options timeout:2
On Ubuntu 18.04+ and modern Debian systems, DNS is managed by systemd-resolved:
# View DNS status
resolvectl status
# Query DNS for a specific domain
resolvectl query rexe.tr
# Flush DNS cache
resolvectl flush-caches
# View DNS statistics
resolvectl statistics
# Persistent DNS setting with systemd-resolved
sudo nano /etc/systemd/resolved.conf
[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1
Domains=rexe.tr
DNSSEC=no
DNSOverTLS=no
# Restart the service
sudo systemctl restart systemd-resolved
Follow these steps for correct FQDN setup:
# 1. Set hostname
sudo hostnamectl set-hostname webserver01
# 2. Edit /etc/hosts
sudo nano /etc/hosts
127.0.0.1 localhost
127.0.1.1 webserver01.rexe.tr webserver01
203.0.113.100 webserver01.rexe.tr webserver01
# 3. Verify FQDN
hostname -f
# Output: webserver01.rexe.tr
# 4. Verify short hostname
hostname -s
# Output: webserver01
# 5. Verify IP address
hostname -I
A PTR record is a reverse DNS record that resolves an IP address to a hostname.
PTR records are set by the ISP or hosting provider that owns your IP address. You can manage your PTR record from the REXE customer panel.
# Check current PTR record
dig -x 203.0.113.100
# or
nslookup 203.0.113.100
# Expected output:
# 100.113.0.203.in-addr.arpa. IN PTR webserver01.rexe.tr.
dig (Domain Information Groper) is the most powerful tool for testing DNS queries.
# Query A record
dig rexe.tr A
# Query MX record
dig rexe.tr MX
# Query NS record
dig rexe.tr NS
# Query TXT record
dig rexe.tr TXT
# Use a specific DNS server
dig @8.8.8.8 rexe.tr A
# Short output
dig +short rexe.tr A
# Query all records
dig rexe.tr ANY
# Reverse DNS query
dig -x 203.0.113.100
# Check DNS propagation
dig +trace rexe.tr
# Basic query
nslookup rexe.tr
# With specific DNS server
nslookup rexe.tr 8.8.8.8
# Reverse DNS
nslookup 203.0.113.100
# Interactive mode
nslookup
> server 8.8.8.8
> set type=MX
> rexe.tr
> exit
# Basic query
host rexe.tr
# Reverse DNS
host 203.0.113.100
# MX record
host -t MX rexe.tr
# Specific DNS server
host rexe.tr 1.1.1.1
# Start a new shell
exec bash
# or restart the system
sudo reboot
# Check /etc/hostname
cat /etc/hostname
# Test DNS connectivity
dig @8.8.8.8 google.com
# Check resolv.conf
cat /etc/resolv.conf
# Check systemd-resolved status
systemctl status systemd-resolved
# Check nsswitch.conf
cat /etc/nsswitch.conf | grep hosts
# Output: hosts: files dns
For DNS issues, first check /etc/hosts, then /etc/resolv.conf. The hosts line in nsswitch.conf determines the resolution order.
Correct hostname and DNS configuration is one of the cornerstones of server management. Properly setting the FQDN on your REXE servers is critical for email delivery, SSL certificates, and application configurations. You can use the REXE customer panel to ensure your PTR record is correctly configured.
The current terminal session may have cached the old hostname. Apply the change by running 'exec bash' or opening a new terminal. Some applications may require a server restart.
The short hostname is just the machine name (e.g., server01). The FQDN combines the machine name with the domain name (e.g., server01.rexe.tr). Mail servers, SSL certificates, and some applications require FQDN.
PTR records are set by the hosting provider that owns your IP address. You can manage your server's PTR record from the REXE customer panel. Check your current PTR record with 'dig -x YOUR_IP_ADDRESS'.
On modern systems, /etc/resolv.conf is managed by systemd-resolved or NetworkManager. For persistent DNS settings, edit /etc/systemd/resolved.conf and run 'systemctl restart systemd-resolved'.
dig is more modern and provides detailed output; it's preferred for use in scripts. nslookup is older but has a simpler interface. Both tools can diagnose DNS issues, but dig offers more powerful options.
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Complete guide to connecting to Windows Server VDS via Remote Desktop (RDP): setup steps, NLA security, Path Panel firewall rule, and troubleshooting tips.
Step-by-step guide to changing your VDS server OS via REXE panel: backup tips, supported Linux distributions and Windows Server versions explained.