How to modify the IP address and hostname in Linux

Source: Internet
Author: User

Querying and modifying host information
I. How to modify the Linux host name
 
1. Change the current host name
1.1 echo New-hostname>/proc/sys/kernel/hostname (when the system starts, the host name is read from this file)
1.2 hostname New-hostname (effective immediately, but will expire after the system is restarted)
 
2. modify the configuration file so that the new host name is used at the next restart.
 
2.1 edit the file:/etc/sysconfig/Network
2.2 modify: Hostname = new-hostname.domainname
 
By modifying the hostname in the/etc/sysconfig/network file, you can set a new host name. Of course, you need to reactivate the host to take effect; next, modify the/etc/hosts file. Next, describe the file content in hosts. The content is as follows:
 
127.0.0.1 localhost. localdomain localhost (IPv4)
 
: 1 localhost. localdomain localhost6 (IPv6)
 

3. Configure the local domain name resolution file so that the local application can resolve the new host name
 
3.1 edit the file:/etc/hosts
Modify: XXX. XXX new-hostname.domainname New-hostname (here XXX represents the local network
 
Network Address, which can also be the loopback address 127.0.0.1 ).
 
 
 
4. Modify through the graphic interface
 
Run the neat command to open the following interface (be familiar with it)
 

Note: The/etc/hosts file is mainly for parsing. hosts is only used to explain the host in the network and the corresponding IP Address File for querying the host of the hosts owner; therefore, you can directly modify the network file to modify the host name. Of course, you should also modify the hosts document. Of course, you only need to modify the network document, which will take effect after restart.
 
 
 
Ii. How to view Host IP information
 
1. Use the hostname command to obtain host and IP information
 
Hostname-A: Get the host alias.
 
Hostname-D: Obtain the DNS domain name.
 
Hostname-F: Get the FQDN name.
 
Hostname-I: Obtain the IP address of the host.
 
Hostname-S: Get the NetBIOS Name of the domain name.
 
 
 
2. ifconfig
 
Ifconfig: view all network interface information (including other information, such as IP address, MAC address, and MTU value)
 

Ifconfig-Interface: view the specified interface information (including IP information)

For reprint, please indicate the source and original article links:

Http://blog.csdn.net/xiangsir/article/details/8570427

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.