When we use the CentOS system, we may feel that some settings are not suitable for ourselves. although they do not cause great errors, they do cause us a lot of trouble, next I will give you some suggestions to modify your DNS, Gateway, and IP address. Let's explain how to modify it! 1. the CentOS system modifies the DNS configuration file of the corresponding Nic.
When we use the CentOS system, we may feel that some settings are not suitable for ourselves. although they do not cause great errors, they do cause us a lot of trouble, next I will give you some suggestions to modify your DNS, Gateway, and IP address. Let's explain how to modify it!
1. modify DNS in CentOS
Modify the DNS configuration file of the corresponding Nic
Modify the following content
| 12 |
Nameserver 8.8.8.8 # google domain name server nameserver 8.8.4.4 # google domain name server |
2. CentOS system gateway modification
Modify the gateway configuration file of the corresponding Nic
| 1 |
[Root @ centos] # vi/etc/sysconfig/network |
Modify the following content
| 123 |
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 start) HOSTNAME = centos (set the host name of the local machine, the host name set here corresponds 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 the IP address of the CentOS system
Modify the configuration file of the corresponding nic ip address
| 1 |
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0 |
Modify the following content
| 12345678910 |
DEVICE = eth0 # describe the DEVICE alias corresponding to the NIC, for example, in the ifcfg-eth0 file it is eth0BOOTPROTO = static # set the way the Nic gets the IP address, possible options are static, dhcp or bootp, corresponding to static IP addresses, IP addresses obtained through dhcp, IP addresses obtained through the bootp protocol BROADCAST = 192.168.0.255 # corresponding subnet BROADCAST address HWADDR = 00: 07: E9: 05: e8: B4 # The physical IP address of the corresponding network adapter IPADDR = 12.168.1.2 # If you set the network adapter's IP address to be statically specified, this field specifies the IP address IPV6INIT = no00006_autoconf = noNETMASK = 255.255.255.0 # NETWORK mask NETWORK = 192.168.1.0 # NETWORK address of the NETWORK adapter ONBOOT = yes # whether to set the IP address when the system starts. this network interface, when set to yes, the device is activated when the system starts. |
4. restart the network configuration.
| 1 |
Service network restart |
Or
| 1 |
/Etc/init. d/network restart |
Modify IP address
Effective immediately:
| 1 |
Ifconfig eth0 192.168.0.2 netmask 255.255.255.0 |
Start effective:
Modify
| 1 |
/Etc/sysconfig/network-scripts/ifcfg-eth0 |
Modify Gateway Default Gateway
Effective immediately:
| 1 |
Route add default gw 192.168.0.1 dev eth0 |
Start effective:
Modify
Modify DNS
Modify
The modification takes effect immediately and starts as well.
Modify host name
Effective immediately:
Start effective:
Modify
In the CentOS system, we have modified the DNS, Gateway, and IP address. after restarting the network configuration, we can see the effect.