After installing Linux, it is necessary to do some simple configuration to normal use, such as network, firewall, security settings and so on, but also need to install some required software. Only after this series of configuration can be considered normal use.
The network is one of the most important functions, so be sure to configure it, otherwise you will not be able to network
Dynamic Network
Dynamic networks can use IP addresses assigned by DHCP servers. Input Vi/etc/sysconfig/network-scripts/ifcfg-eth0 will show the following screen
Edit Linux Network card properties
When CentOS was just installed, it was DHCP by default, but the NIC was not enabled. That is to be in the onboot= "no", the option is changed to Yes, otherwise the network card does not automatically online, will lose its role. When you are done, press ESC to code mode and enter ": Wq" (without quotes) to save the exit. Explain, the W parameter is saved meaning, q is exit, two parameters together is to save and exit the meaning.
Static Network
As a server, it is best to use a static network and assign it a legitimate IP address. or use the command to edit the network card properties vi/etc/sysconfig/network-scripts/ifcfg-eth0 to the following image
Edit Linux static network card properties
To change the bootprot= "DHCP" to static, that is, to statically address. Add three records: Ipaddr= "172.18.4.199" (Here I give the allocation of the 172.18.4.199 as an example), the back of the netmask is the subnet mask, Gateway is gateways. After filling out, still press ESC and then: Wq save. In order for the settings to take effect to restart Linux, there are two ways to reboot, one is the reboot command, the other is shutdown-r now.
After setting the IP address and subnet mask, you can ping the gateway to see the return value if you want the settings to be effective.
It seems to have ping the gateway, but ping the extranet address is not a pass. What is this for? Yes, it is not set DNS, so the domain name can not be resolved, this time to DNS settings, the command is as follows: vi/etc/resolv.conf, add two records
| The code is as follows |
Copy Code |
NameServer 8.8.8.8 NameServer 8.8.4.4 |
Here take Google's DNS as an example, the actual local DNS is the subject. After setting up, reboot restart the network is normal.