Modify the Host IP address and host name in Linux.
**************************************** ******************************** **************
Original Works are from the blog of "Deep Blue blog". You are welcome to repost them. Please indicate the source when you repost them. Otherwise, the copyright will be held legally responsible.
Please leave a message or email (hyldba@163.com) indicating that there is an error. Thank you very much.
This article reprint must be kept here: http://blog.csdn.net/huangyanlong/article/details/39214985
Deep Blue blog: http://blog.csdn.net/huangyanlong
**************************************** **************************************** *******************
1. modify Network Configuration
Last login: Sat Sep 6 17:33:02 2014
[Root @ centos ~] #Vi/etc/sysconfig/network-scripts/ifcfg-eth0
-- Before modification
# Intel Corporation 82540EM GigabitEthernet Controller
DEVICE = eth0
BOOTPROTO = dhcp
ONBOOT = yes
HWADDR = 08: 00: 27: 80: 63: 5b
~
~
-- After modification
# Intel Corporation 82540EM GigabitEthernet Controller
DEVICE = eth0
BOOTPROTO = static
IPADDR = 10.53.105.65
NETMASK = 255.255.255.0
ONBOOT = yes
HWADDR = 08: 00: 27: 80: 63: 5b
~
[Root @ centos ~] #Service network restart
Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
Bringing up interface eth0: RTNETLINK answers: Invalid argument
[OK]
2. Modify the hosts Configuration
[Root @ centos ~] #Vi/etc/hosts
# Do not remove the following line, orvarious programs
# That require network functionality willfail.
127.0.0.1 centos localhost. localdomainlocalhost
: 1 localhost6.localdomain6 localhost6
10.53.105.65 hyldb
~
~
3. Modify the network configuration
[Root @ centos ~] #Vi/etc/sysconfig/network
-- Before modification
NETWORKING = yes
NETWORKING_IPV6 = yes
HOSTNAME = centos
GATEWAY = 10.53.105.255
~
~
-- After modification
NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = hyldb
GATEWAY = 10.53.105.255
~
~
-- Restart the system to make the configuration take effect.
[Root @ centos ~] #Reboot
Broadcast message from root (pts/3) (SunSep 7 00:00:08 2014 ):
The system is going down for reboot NOW!
After the restart, the effect is as follows:
Last login: Sat Sep 6 23:55:38 2014 from 10.53.105.69
[Root @ hyldb ~] #Ifconfig
Eth0 Link encap: Ethernet HWaddr08: 00: 27: 80: 63: 5B
Inet addr: 10.53.105.65 Bcast: 10.53.105.255 Mask: 255.255.255.0
Inet6 addr: fe80: a00: 27ff: fe80: 635b/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 44 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 73 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 5283 (5.1 KiB) TXbytes: 10654 (10.4 KiB)
Lo Link encap: Local Loopback
Inet addr: 127.0.0.1 Mask: 255.0.0.0
Inet6 addr: 1/128 Scope: Host
Up loopback running mtu: 16436 Metric: 1
RX packets: 5900 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 5900 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 txqueuelen: 0
RX bytes: 10634248 (10.1 MiB) TXbytes: 10634248 (10.1 MiB)
[Root @ hyldb ~] #Hostname
Hyldb
[Root @ hyldb ~] #
**************************************** ******************************** **************
Original Works are from the blog of "Deep Blue blog". You are welcome to repost them. Please indicate the source when you repost them. Otherwise, the copyright will be held legally responsible.
Please leave a message or email (hyldba@163.com) indicating that there is an error. Thank you very much.
This article reprint must be kept here: http://blog.csdn.net/huangyanlong/article/details/39214985
Deep Blue blog: http://blog.csdn.net/huangyanlong
**************************************** **************************************** *******************
Does the linux host name automatically change to an IP address? Without any settings, how can I avoid changes?
I used to encounter this situation. Later I found that the host name was set for the NIC. When I restarted, I read the NIC configuration again. View the eth0 or eht1 configuration, which should be written in. /Etc/sysconfig/network-stript/eth0 or eth1
In addition, if your IP address is automatically allocated by DHCP, the name may also be automatically allocated by DHCP.
For other modification methods, refer to my friends on the first floor.
How can I change the linux host name?
Many people use the hostname to modify the host name. In fact, this is only for the moment. After restarting, it will be restored to the original name.
Many people say that the host name in the/etc/hosts file is only provided for dns resolution. if you cannot use dns, you only need to modify the host name.
In fact, it is to modify the host name in the file etc/sysconfig/network.
NETWORKING = yes
HOSTNAME = Host Name
------------------------------------------------------------------------
Remember to restart !!!
------------------------------------------------------------------------
Complete:
Step 1:
# Hostname oratest
Step 2:
Modify the hostname in/etc/sysconfig/network
Step 3:
Modify the/etc/hosts file
Www.ititgo.com
Reference: www.ititgo.cn/news_view.asp? Newsid= 562