In the use of CentOS system, we may feel that some settings are not suitable for themselves, although not cause a lot of mistakes, but it does bring us a lot of small trouble, I would like to give you some suggestions, modify your DNS, gateway and IP address. Then let's explain how to modify it!
1, CentOS system to modify DNS
To modify the DNS profile of the corresponding network adapter
# vi/etc/resolv.conf
Modify the following content
NameServer 8.8.8.8 #google域名服务器
NameServer 8.8.4.4 #google域名服务器
2. CentOS System Modification Gateway
Modify the configuration file for the gateway that corresponds to the network card [root@centos]# vi/etc/sysconfig/network
Modify the following content
Networking=yes (Indicates whether the system is using the network, typically set to Yes.) If set to no, the network cannot be used, and many system services programs will not start.
Hostname=centos (sets the host name for this machine, where the host name is set to correspond to the hostname set in/etc/hosts)
gateway=192.168.1.1 (Sets the IP address of the gateway for this computer connection.) For example, the gateway is 10.0.0.2)
3, CentOS system modification 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, Ifcfg-eth0 in a file that is eth0
Bootproto=static #设置网卡获得ip地址的方式, possible options for STATIC,DHCP or BOOTP, respectively corresponding to statically specified IP address, IP address obtained through DHCP protocol, IP address obtained through 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 network adapter
Ipv6init=no
Ipv6_autoconf=no
netmask=255.255.255.0 #网卡对应的网络掩码
network=192.168.1.0 #网卡对应的网络地址
Onboot=yes #系统启动时是否设置此网络接口, when set to Yes, this device is activated when the system starts
4. Restart 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
Start in effect:
Modify/etc/sysconfig/network-scripts/ifcfg-eth0
Modify Gateway Default Gateway
Immediate effect:
Route add default GW 192.168.0.1 dev eth0
Start in effect:
Modify/etc/sysconfig/network
Modify DNS
Modify/etc/resolv.conf
Can be effective immediately after modification
Modify Host Name
Immediate effect:
Hostname CENTOS1
Start in effect:
Modify/etc/sysconfig/network
CentOS system, we have completed the DNS, gateway, IP address changes, restart the network configuration, we can see the effect.