When using the CentOS system, we may feel that some settings are not suitable for us. Although it will not cause major mistakes, it does bring us a lot of small troubles. Now I will give you some suggestions and modify them. Your DNS, gateway and IP address. So let's explain how to modify it!
1. The CentOS system modifies the DNS to modify the DNS configuration file of the corresponding network card # 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 2. CentOS system modify the gateway to modify the corresponding network card The configuration file of the gateway [root@centos]# vi /etc/sysconfig/network Modify the following content NETWORKING=yes (indicates whether the system uses the network, generally set to yes. If it is set to no, the network cannot be used, and many system services The program will not be able to start) HOSTNAME=centos (set the host name of the machine, the host name set here should correspond to the host name set in /etc/hosts) GATEWAY=192.168.1.1 (set the IP address of the gateway connected to the machine. For example, the gateway is 10.0.0.2) 3. The CentOS system modifies the IP address and modifies the configuration file corresponding to the IP address of the network card # vi /etc/sysconfig/network-scripts/ifcfg-eth0 Modify the following content DEVICE=eth0 #Describe the device corresponding to the network card Alias, for example, in the file of ifcfg-eth0, it is eth0 BOOTPROTO=static #Set the way the network card obtains the ip address, the possible options are static, dhcp or bootp, which correspond to the statically specified ip address, and the ip address obtained through the dhcp protocol, IP address obtained through the bootp protocol
BROADCAST=192.168.0.255 #The corresponding subnet broadcast address
HWADDR=00:07:E9:05:E8:B4 #The corresponding network card physical address
IPADDR=12.168.1.2 #If the method of setting the network card to obtain the ip address is statically specified, this The field specifies the ip address corresponding to the network card
IPV6INIT=no
IPV6_AUTOCONF=no
NETMASK=255.255.255.0 #Network mask corresponding to the network
card NETWORK=192.168.1.0 #Network address corresponding to the network card
ONBOOT=yes #Whether this network interface is set when the system starts , when set to yes, the device will be activated when the system starts
4. Restart the network configuration service network restart or /etc/init.d/network restart Modify the IP address to take effect immediately: ifconfig eth0 192.168.0.2 netmask 255.255.255.0 Start to take effect: modify /etc/sysconfig/network-scripts/ifcfg-eth0 Modify the gateway Default Gateway takes effect immediately: route add default gw 192.168.0.1 dev eth0 starts to take effect: Modify /etc/sysconfig/network Modify DNS Modify /etc/resolv.conf
修改后可即时生效,启动同样有效
修改 host name
即时生效:
hostname centos1
启动生效:
修改/etc/sysconfig/network
CentOS系统中,我们就完成了DNS、网关、IP地址的修改,重新启动网络配置后,我们就可以看到效果了。