Modify host name and network information in CentOS
1. Modify host name
[Root @ centos ~] # Vim/etc/sysconfig/network
Open the file, modify the following content, and save
NETWORKING = yes # use the network
HOSTNAME = centos # Set Host Name
[Root @ centos ~] # Hostname centos # effective immediately
2. Modify the NIC
[Root @ centos ~] # Vim/etc/sysconfig/network-scripts/ifcfg-eth0
Open the file, modify the following content, and save
DEVICE = eth0 # corresponds to the first Nic
TYPE = Ethernet
ONBOOT = yes # run at startup
NM_CONTROLLED = yes
BOOTPROTO = static # use a static IP address instead of an IP address allocated by DHCP
DEFROUTE = yes
20174_failure_fatal = yes
IPV6INIT = no
NAME = "System eth0" # NAME
HWADDR = 00: 50: 56: 94: 04: 3C # It must correspond to the MAC address of etho (/etc/udev/rules. d/70-persistent-net.rules)
PEERDNS = yes
PEERROUTES = yes
IPADDR = 192.168.1.128 # specify the local IP Address
NETMASK = 255.255.255.0 # specify the subnet mask
GATEWAY = 192.168.1.2 # specify the GATEWAY
DNS1 = 192.168.1.2
3. Modify DNS [root @ centos ~] # Vim/etc/resolv. conf
Open the file, modify the following content, and save
Nameserver 8.8.8.8 # GOOGLE's DNS Server
Nameserver 192.168.1.2 # specify the DNS server specified on the router
4. Restart the network configuration [root @ centos ~] # Service network restart
5. Restart
[Root @ centos ~] # Reboot
6. view the current IP settings
[Root @ centos ~] # Ifconfig
7. Test whether to connect to the Internet
[Root @ centos ~] # Ping www.centoscn.com