Run the command to modify the host name
Hostname # view the host name of the current host
Hostname NEWHOSTNAME # temporarily modify the current host name
Modify the host name in the configuration file
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
Modify hosts
Vi/etc/hosts
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
Network Configuration
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
Modify DNS
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
Other commands
##########################
#
#/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
##########################
#
# 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
##########################
#
# 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
##########################
#
# 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
Redhat modify host name and network configuration