1. Modify the IP address of centos
Modify the configuration file of the corresponding Nic IP Address
- #VI/Etc/sysconfig/network-scripts/ifcfg-eth0
-
- Modify the following content
- Device = eth0# Describe the device alias corresponding to 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 option isStatic, DHCP, or BOOTP, which correspond toIP address, IP address obtained through the DHCP protocol, IP address obtained through the BOOTP protocol
- Broadcast = 192.168.0.255# Corresponding subnet broadcast address
- Hwaddr = 00: 07: E9: 05: E8: B4# The physical address of the corresponding Nic
- Ipaddr = 12.168.1.2# If you set the NIC to getThe IP address is specified statically. In this field, the IP address corresponding to the NIC is specified.
- Ipv6init = No
- Ipv6_autoconf = No
- Netmask = 255.255.255.0# Network mask corresponding to the NIC
- Network = 192.168.1.0# Network address corresponding to the NIC
- Onboot = Yes# Whether to set this network interface when the system starts. If it is set to yes, this 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 netmask1_255.255.0
Start effective:
Modify/Etc/sysconfig/network-scripts/ifcfg-eth0
Modify the ultgateway
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 hostname
Effective immediately:
# Hostname centos1
Start effective:
Modify/Etc/sysconfig/Network
My settings:
[Root @ cloud/] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0
# Intelcorporation 82567lm-3 Gigabit networkconnection
Device = eth0
Bootproto = static
Broadcast = 192.168.77.255
Hwaddr = D4: 85: 64: 94: 57: 0f
Ipaddr = 192.168.77.34
Netmask = 255.255.255.0
Network = 192.168.77.0
Onboot = Yes
[Root @ cloud/] # Cat/Etc/sysconfig/Network
Networking = Yes
Networking_ipv6 = No
Hostname = cloud
Gateway = 192.168.77.254
[Root @ cloud/] # Cat/Etc/resolv. conf
Nameserver210.42.35.35