Manually configure a static IP address
That is, manually configuring IP addresses, subnet masks, gateways, and DNS.
The Setup method is as follows:
vi /etc/sysconfig/network-scripts/ifcfg-eth0编辑本地网卡的配置文件
See whether the following are the same as given below.
ONBOOT=yesBOOTPROTO=noneIPADDR=192.168.1.66NETMASK=255.255.255.0GATEWAY=192.168.1.1DNS1=192.168.1.1
The second entry indicates that the DHCP service is not used, and if the static IP address is configured manually, the value of Bootproto can be none or static.
The third item indicates that the IP address is set.
The fourth item represents setting the subnet mask.
The fifth item indicates setting up the gateway.
The sixth item is to set the preferred DNS server, in fact, DNS has its own configuration file/etc/resolv.conf, where DNS is set to write it to the DNS configuration file/etc/resolv.conf.
Then, execute the following command to restart the network service.
Note: in the case of Linux for virtual machines, using "Manually configure static IP addresses", you must set the network connection mode for this virtual machine's network adapter (that is, the NIC) to bridge mode.
Regardless, whether it is "automatically get dynamic IP address" or "Manually configure static IP address", can be configured to configure the IP address of Linux, and is permanently in effect. And, as long as your home has an extranet, your Linux can also connect to the extranet. But I prefer to use "Get dynamic IP address automatically" because it is more convenient.
Summary: modify the network card configuration file This method is very effective, almost no limitations, it is strongly recommended.
Linux manually configure IP address methods