In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to set up the CentOS7 virtual machine to use static IP to access the Internet, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
Recently, I played Centos in the VMware virtual machine. After installing it, I found that I couldn't get on the Internet. After a lot of hard work, we finally found a solution to the problem. The final result is that whether it is ping internal network IP or ping external network ip, it can communicate with ping normally. The method is four steps:
In the first step, we go to the / etc/sysconfig/network-scripts directory to see if there are any files like ifcfg-XXX:
If you can't see the file that starts with ifcfg- (except ifcfg-lo), the network card device is not recognized correctly. It may be that the version of centos image you downloaded is different from the version of centos you chose when installing centos. For example, the centos image is 64-bit, but it is installed according to 32-bit. This. Reinstall it, at least I didn't find a good way.
Let's proceed to the second step:
In VMware, click "Edit"-"Virtual Network Editor". As shown in the following figure, I chose NAT mode:
To be able to use static IP, do not check the option "assign IP to virtual machines using local DHCP services" here. Then it is to configure the subnet ip. The subnet IP and the ip of the host must not be in the same address range, otherwise even if the virtual machine accesses the Internet, the network is slow and unstable. The ip segment of my host is 192.168.115.xxx, so I configured 192.168.10.xxx to avoid the ip segment of the host. Anyway, the third number of ip is between 0 and 254 and not 115. Nat mode is equivalent to configuring a sub-router, and friends who have set up multi-level routing should have some experience. Please configure a subnet ip reasonably according to the IP of your machines.
Click "NAT Settings" in this interface to view the virtual machine gateway, which you will use in step 3. My gateway here is 192.168.10.2.
Step 3:
Edit the file / etc/sysconfig/network-scripts/ifcfg-eno16777736 with root permissions, and the effect is as follows:
TYPE=EthernetBOOTPROTO=static # set static IpDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noNAME=eno16777736UUID=4f40dedc-031b-4b72-ad4d-ef4721947439DEVICE=eno16777736ONBOOT=yes # if it is no, change it to yes, indicating that the network card device automatically starts PEERDNS=yesPEERROUTES=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_PRIVACY=no GATEWAY=192.168.10.2 # the gateway address here is the gateway address obtained in the second step, IPADDR=192.168.10.150 # configure ip. In the second step, ip has been set to the range of 192.168.10.xxx, so I'll just set it to 150. As long as it is not the same as the gateway, you can NETMASK=255.255.255.0# the subnet mask DNS1=202.96.128.86#dns server 1 and fill in the available dns server address of your network to DNS2=223.5.5.5#dns server 2
I have marked all the key parameters with color shading, and keep the rest by default. Save and exit after confirmation.
Step 4: restart the network card service, execute service network restart, and finally get online:
Domain name of Baidu under ping
Open the browser and find that the web page is open.
Finally, the effect picture of the communication between the virtual machine and the intranet ip will not be posted, of course. Personal expression can be poor, please make do with it, I hope it can help you.
2019-09-17 add: if the host ping is not connected to the virtual machine, the ip of the network connection VMware Virtual Ethernet Adapter for VMnet8 in the host can be set to the same network segment as the virtual machine ip, and the default gateway can be left blank:
Thank you for reading this article carefully. I hope the article "how to set up a CentOS7 virtual machine to access the Internet using static IP" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.