1. modify the IP address of CentOS to modify the configuration file of the IP address of the corresponding Nic. if only one Nic is eth0, and so on # vi/etc/sysconfig/network-scripts/ifcfg-eth0 modify the following content DEVICE = eth0 # describe the DEVICE alias corresponding to the NIC, such as ifcfg-
1. modify the IP address of CentOS
Modify the configuration file of the corresponding nic ip address. if only one Nic is eth0, and so on
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the following content
DEVICE = eth0 # describe the DEVICE alias for the NIC, for example, it is eth0 in the ifcfg-eth0 file
BOOTPROTO = static # set the way for the NIC to obtain the IP address. the possible options are static, dhcp, or bootp, which respectively correspond to the IP address specified by the static state and the IP address obtained through the dhcp protocol, IP addresses obtained through the bootp protocol
BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address
HWADDR = 00: 07: E9: 05: E8: B4 # physical address of the corresponding Nic
IPADDR = 12.168.1.2 # if the method for obtaining IP addresses from the network adapter is static, This field specifies the IP address of the network adapter.
IPV6INIT = no
IPV6_AUTOCONF = no
NETMASK = 255.255.255.0 # network mask corresponding to the network adapter
NETWORK = 192.168.1.0 # NETWORK address of the NIC
ONBOOT = yes # whether to set this network interface when the system starts. if it is set to yes, the device is activated when the system starts.
II. CentOS gateway modification
Modify the gateway configuration file of the corresponding Nic
[Root @ centos] # vi/etc/sysconfig/network
Modify the following content
NETWORKING = yes (indicates whether the system uses the network, which is generally set to yes. If it is set to no, the network cannot be used, and many system service programs cannot be started)
HOSTNAME = centos (set the host name of the local machine. the host name set here must correspond to the host name set in/etc/hosts)
GATEWAY = 192.168.1.1 (set the IP address of the GATEWAY connected to the local machine. For example, the gateway is 10.0.0.2)
3. modify DNS in CentOS
Modify the DNS configuration file of the corresponding Nic
# Vi/etc/resolv. conf
Modify the following content
Nameserver 8.8.8.8 # google domain name server
Nameserver 8.8.4.4 # google domain name server
4. restart network configuration
# Service network restart
Or
#/Etc/init. d/network restart
Modify IP address
Effective immediately:
# Ifconfig eth0 192.168.0.2 netmask 255.255.255.0
Start effective:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify Gateway Default Gateway
Effective immediately:
# Route add default gw 192.168.0.1 dev eth0
Start effective:
Modify/etc/sysconfig/network
Modify DNS
Modify/etc/resolv. conf
The modification takes effect immediately and starts as well.
Modify host name
Effective immediately:
# Hostname centos1
Start effective:
Modify/etc/sysconfig/network