On the forum, you can see that you need to change/proc/sys/kernel/hostname to <xmlnamespace prefix = "o" ns = "urn: schemas-microsoft-com: office"
/>
How to modify the host name in linux
You can use the hostname command to temporarily modify the machine name, but the original value will be restored after the machine is restarted.
# Hostname
// View the machine name
# Hostname-I // view the IP address corresponding to the machine name
Another method is to modify the configuration file for a long time.
Modify/etc/sysconfig/network
This file is valid only when it is modified.
Run the/etc/hosts hostname command to read this configuration file.
Many friends on the Internet say that you can directly modify the/etc/hosts file, but the host name used by the system will not change, so I think
/Etc/hosts
Is Used in the network,/etc/sysconfig/network is used on the local machine, and the meridian test is also like this, my version is
Linux as3
Conclusion: To modify the host name, both files must be changed.
Another article about the/etc/hosts file
1.
About/etc/host, host name and IP configuration file
Hosts-The static table lookup for host name (host name query static table)
Linux
/Etc/hosts is the file that configures the IP address and its corresponding host name. Here, the IP address of the local host or other hosts and its corresponding host name can be recorded. This configuration file may be different for different Linux versions. For example, Debian's corresponding file is/etc/hostname.
2.
Configuration File
This file can be used to configure the Host IP address and the corresponding host name. The role of this file on a server-type Linux system cannot be ignored. On a LAN or internet, each host has an IP address, which separates each host and can communicate with each other based on the IP address. But the IP address is not easy to remember, so there is a domain name.
In a LAN, each machine has a host name, which is used to distinguish hosts for mutual access.
The configuration file for the Linux host name is/etc/hosts. This file tells the host which domain names correspond to those IP addresses and which IP addresses correspond to those host names:
For example, this definition exists in the file.
192.168.1.100 linumu100 test100
Suppose 192.168.1.100 is a website server. Enter http: // linumu100 or http: // test100 on the webpage to open the web page 192.168.1.100.
Generally, this file records the local IP address and Host Name:
127.0.0.1 localhost. localdomain localhost
3.
Configuration file format description
General/etc/hosts
The content of is generally similar to the following:
127.0.0.1 localhost. localdomain localhost
192.168.1.100 linmu100.com linmu100
192.168.1.120 ftpserver ftp120
In general, each action of the hosts file is a host. Each line consists of three parts, separated by spaces. The line starting with # is not explained by the system.
Part 1: network IP address;
Part 2: Host Name or domain name;
Part 3: Host Name alias;
Of course, each line can also be two parts, namely the Host IP address and host name; for example, 192.168.1.100 linmu100.
Here we can slightly explain the differences between the host name (hostname) and domain name (domain): The host name is usually used in the LAN. Through the hosts file, the host name is resolved to the corresponding IP address; domain names are usually used on the Internet, but if the local machine does not want to use domain name resolution on the internet,
In this case, you can change the hosts file and add your own domain name resolution.
4. What problems can the/hosts file help solve?
4.1
Slow remote logon to Linux Hosts
Sometimes the client wants to remotely log on to a Linux host, but it will wait a long time after entering the password. This is because the Linux host needs to resolve the IP address when returning information, if you add the IP address of the client to the hosts file of the Linux host, then remote Linux Login from the client will become very fast.
Note: Remote logon is not only about SSH, but also about MySQL remote logon or file sharing query.
4.2
Dual-host Interconnection
When the two hosts are connected by two machines, you must set your own IP address and add your own IP address and host name to the hosts file of the other host.
5.
Hostname modification Tool;
In fact, there is also a dedicated tool for modifying the host name, that is, the hostname
Hostname-show or set the system's host name
Show Host Name:
# Hostname
Linmu100
The host name of this host is linmu100, and the Host Name of the current host is displayed without parameters;
Set the host name temporarily:
# Hostname test100
# Hostname
Note: The host name is displayed.
Test100
By hostname
Tool to set the host name is only temporary, the host name will not exist the next time you restart the system;
Display Host IP Address:
# Hostname-I
192.168.1.100
Linux
After installation, the default name is localhost.
1. Modify/etc/sysconfig/network
Configuration File
Vi/etc/sysconfig/network
Ssh
Modify HOSTNAME
HOSTNAME = new-hostname.domainname ssh
Change my network:
HOSTNAME = redhat5.dong.com.
Ssh
2. Modify the local domain name resolution file/etc/hosts
To make the local application
New host names can be resolved.
Vi/etc/hosts
Mysql
Set
127.0.0.1 localhost. localdomain localhost
Change to: 127.0.0.1 new-hostname.domainname New-hostname
Mine is
127.0.0.1 redhat5.dong.com redhat5
Restart and use the new host name.
OK!