From http://memo.cnticketing.com/uchome/space.php? Uid = 2 & Do = Blog & id = 6
RedHat Linux host name modification (hostname)
Hostname # view the Host Name of the current host
Hostname newhostname # Temporarily modify the current host name
Modify host name
VI/etc/sysconfig/Network # modify the host name through the configuration file
Networking = Yes
Hostname = newhostname # modify this value as the host name, for example, newpc
VI/etc/hosts
#
##########################
VI/etc/hosts // set the local DNS resolution File
127.0.0.1 localhost. localdomain localhost // This row is strongly recommended
192.168.0.1 rhel.lpwr.net RHEL // there must be three fields: IP, FQDN, and hostname
##########################
To:
RHEL basic network configuration
######################################## ##
#/Etc/sysconfig/network-scripts/ETH
######################################## ##
VI/etc/sysconfig/network-scripts/eth0 // edit the configuration file of the specified network interface
Device = eth0 // specify the Interface Name
Onboot = Yes // load when the system starts
Bootproto = static // static IP Address Configuration. If the value is "DHCP", it is dynamically obtained.
Ipaddr = 192.168.0.1 // set the IP address
Netmask = 255.255.255.0 // sets the subnet mask.
Gateway = 192.168.0.254 // set the Default Gateway
##########################
#
#/Etc/sysconfig/Network
#
##########################
VI/etc/sysconfig/network // modify the host name through the configuration file
Networking = Yes
Hostname = localhost. localdomain // modify this value as the host name, for example, rhel.lpwr.net
##########################
#
#/Etc/hosts
#
##########################
VI/etc/hosts // set the local DNS resolution File
127.0.0.1 localhost. localdomain localhost // This row is strongly recommended
192.168.0.1 rhel.lpwr.net RHEL // there must be three fields: IP, FQDN, and hostname
##########################
#
#/Etc/resolv. conf
#
##########################
VI/etc/resolv. conf // specifies the DNS server of the current host. A maximum of three DNS servers can be specified.
Search lpwr.net // set the default search domain of the current host
Nameserver 192.168.0.100 // specify the preferred DNS Server
Nameserver 172.16.254.2
##########################
#
#/Sbin/ifconfig
#
##########################
/Sbin/ifconfig // display the ifconfig command to view Network Interface Information
Ifconfig eth0 // display the information of the specified Interface
Ifconfig-A // display information of all interfaces (whether active or not)
Ifconfig eth0 192.168.0.2 netmask 255.255.255.0 // temporarily modify the interface IP address (no need to restart the interface)
##########################
#
#/Sbin/route
#
##########################
/Sbin/route // display the route table information of the current Linux host
Route del default GW 192.168.0.1 // temporarily Delete the default gateway 192.168.0.1
Route add-net 192.168.1.0/24 GW 192.168.0.254 // temporarily Add a static route
##########################
#
# Ping
#
##########################
Ping // test the network connection with other hosts
Ping-C 4 192.168.0.1 // specify the number of ICMP packets sent
##########################
#
# Traceroute
#
##########################
Traceroute // test the network connection from the current host to the destination
##########################
#
# Hostname
#
##########################
Hostname // view the Host Name of the current host
Hostname linsrv // temporarily modify the current host name
##########################
#
# NSLookup
#
##########################
NSLookup // test DNS domain name resolution
> Server // display the current DNS Server
> Server 192.168.0.1 // temporarily specify the DNS server address
##########################
#
# Dhclient
#
##########################
Dhclient // apply for network configuration information for the current host
##########################
#
# Netconfig
#
##########################
Netconfig // use the Wizard to modify network configuration information on the Character Interface
##########################
#
#/Etc/init. d/Network
#
##########################
/Etc/init. d/network restart // restart the network service
/Etc/init. d/network stop // STOP THE NETWORK SERVICE
/Etc/init. d/network start // start the network service
/** You must restart the network service to modify the network configuration information through netconfig or by modifying the configuration file **/
##########################
#
# Service
#
##########################
Service Network start // start a network service
Service Network stop // stop a network service
Service Network restart // restart the network service
Service Network Status // view the network service status
/** In RHEL4, you can use service commands to manage the startup, stop, restart, and view the working status of most services **/
##########################
#
# Chkconfig
#
##########################
Chkconfig -- list | grep network // view the Automatic startup level of a service
Chkconfig -- level 35 network off // set that a service is not automatically started at Level 35
Chkconfig -- level 3 network on // set level 3 to automatically start a service
##########################
#
# Ntsysv
#
##########################
Ntsysv // use the Wizard to modify the auto-start options of the service on the Character Interface
Nameserver 202.106.0.20