There are many systems that use the linux kernel. Currently, centos, fdeora, and redha systems are the most popular ones. Some of these are charged for free, however, this method can be used in the three systems I described.
After installing Linux, log in and modify the file:
| The Code is as follows: |
Copy code |
# Cat/etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE = "eth0 ″ BOOTPROTO = "none" HWADDR = "00: 50: 56: BE: 7A: D8 ″ IPADDR = 192.168.2.108 # IP address, which must be set GATEWAY = 192.168.2.21 # GATEWAY address, which is very important. If this parameter is not set, the LAN cannot be connected to the external network. ONBOOT = "yes" # Set boot to yes UUID = "fe45f058-9ce7-42a4-823c-abe472aad9f2 ″ IPV6INIT = no NETMASK = 255.255.255.0 # Subnet Mask |
After setting, edit the Domain Name Server settings file.
| The Code is as follows: |
Copy code |
# Cat/etc/resolv. conf Nameserver 192.168.2.01 # address of the domain name server. If this parameter is not set, the website cannot be accessed through the domain name. Search hostname # This is equivalent to your local domain name |
Restart the network service after setting.
| The Code is as follows: |
Copy code |
#/Etc/init. d/network restart |
In this way, run the following ifconfig command to check whether your local machine is connected to the Internet. You can use the ping command to test whether the local machine is connected to the Internet.
Tip:
Directly modify/etc/resolv. conf file is useless, the network service will restart according to/etc/sysconfig/network-scripts/ifcfg-eth0 to reload the configuration, if the ifcfg-eth0 does not configure DNS, then resolv. conf will be washed out and then become a null value.
What should we do? There are two solutions:
1. You can also set the DNS server address through the ifcfg-eth0 and automatically modify or generate the resolv. conf file.
2. In the ifcfg-eth0, The PEERDNS parameter can be used to determine whether to modify resolv. conf file, set PEERDNS = yes (this is also the default configuration of the system). When this network device is enabled, resolv is modified or generated. conf file. If you set PEERDNS = no, The resolv is not used. make any changes to the conf file.
Supplement:
When an application needs domain name resolution (for example, ping www. bKjia. c0m), will first read resolv. the conf file obtains the dns server address and then sends a domain name resolution request to the dns server. the conf settings are incorrect or there is no resolv. conf will cause domain name resolution failure.
If the ifcfg-eth0 is configured as DHCP mode, the system default PEERDNS = no, that is, the DNS address obtained by DHCP is modified or the resolv. conf file is generated.
I think there are no special circumstances, do not set up DNS in resolv. conf, you should set the DNS server address in the ifcfg-eth0 for convenience, that is, in line with normal thinking is also easier to maintain and manage.
Note:The Network Setting method is limited to Linux systems managed by rpm packages, such as fedora, redhat, and centos. Other systems may be slightly different.