1. CentOS Modify DNS
Modify the DNS configuration file for the corresponding NIC
# vi/etc/resolv.conf
Modify the following content
NameServer 8.8.8.8 #google域名服务器
NameServer 8.8.4.4 #google域名服务器
2. CentOS Modify Gateway
Modify the configuration file for the gateway for the corresponding network card
[[Email protected]]# vi/etc/sysconfig/network
Modify the following content
Networking=yes (Indicates whether the system uses a network and is generally set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=centos (Set the hostname of this machine, the host name set here should correspond to the hostname set in/etc/hosts)
gateway=192.168.1.1 (Sets the IP address of the gateway for the native connection. For example, the gateway is 10.0.0.2)
3, CentOS modified IP address
Modify the configuration file for the IP address of the corresponding network card
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the following content
Device=eth0 #描述网卡对应的设备别名, for example, in Ifcfg-eth0 file it is eth0
Bootproto=static #设置网卡获得ip地址的方式, the possible options are static,dhcp or BOOTP, corresponding to statically specified IP addresses, IP addresses obtained through the DHCP protocol, IP addresses obtained through the BOOTP protocol
broadcast=192.168.0.255 #对应的子网广播地址
HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址
ipaddr=12.168.1.2 #如果设置网卡获得 IP address is statically specified, this field specifies the IP address of the NIC
Ipv6init=no
Ipv6_autoconf=no
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.1.0 #网卡对应的网络地址
Onboot=yes #系统启动时是否设置此网络接口, when set to Yes, activates the device when the system starts
4. Restart the network configuration
# Service Network Restart
Or
#/etc/init.d/network Restart
Modify IP Address
Immediate effect:
# ifconfig eth0 192.168.0.2 netmask 255.255.255.0
Activation takes effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
To modify the gateway Default gateways
Immediate effect:
# route add default GW 192.168.0.1 dev eth0
Activation takes effect:
Modify/etc/sysconfig/network
Modify DNS
Modify/etc/resolv.conf
Modified to take effect immediately, start the same effective
Modify Host Name
Immediate effect:
# hostname CENTOS1
Activation takes effect:
Modify/etc/sysconfig/network
Manually change CentOS to static IP
1, search first, get the following explanation
IP IP Address
Netmark Subnet Mask
Gateway Default Gateways
HostName Host Name
DomainName Domain Name
DNS DNS for IP
2. Files that need to be modified are often
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/resolv.conf
/etc/hosts
Go Centos IP, DNS settings