Because I always forget where the gateway is to be modified, a bunch of spam articles are generated by Google. Today I found this article is good. Back up it:
Address: http://www.21andy.com/blog/20100227/1717.html
1. Modify the IP address of centos
Modify the configuration file of the corresponding Nic IP Address
Java code
- # 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 you set the method for obtaining the IP address from the NIC to static, this field specifies the IP address of the NIC.
- 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