مكتبة الشروحات

How do I change the hostname of a VPS or Dedicated server via SSH?

Finding the current server's hostname:

  1. Login with SSH as root.
  2. You will see whether your hostname is by entering the command "hostname".
[root@server]# hostname
host.domain.com
[root@server]#

It will display the current hostname. It should be a domain name resolving to your server's main IP address.

To change the server's hostname, please use this procedure:

    1.   Configure /etc/hosts:

 Open the file /etc/hosts with any text editor. It will show the contents similar to this.

127.0.0.1 localhost.localdomain localhost
10.10.10.10 server.mydomain.com server

Replace the second line with your server's main IP address and hostname.

   2.   Setup the hostname using the command "hostname"

Type this command to change the hostname;

hostname host.domain.com

   3.   Edit the file /etc/sysconfig/network (CentOS)
         Edit the file /etc/hostname (Debian)

Replace the "HOSTNAME" field with your server's new hostname.

After editing the file should look like this:

NETWORKING=yes
HOSTNAME=host.domain.com
 
 

  • hostname, vps, server, change hostname, host name, ssh

هل كانت المقالة مفيدة ؟

2027 أعضاء وجدوا هذه المقالة مفيدة