The latest server development may require a testing environment, so I had to build a virtual machine to install Linux, just as centos 6.0 was released, so I was prepared to try again. I was originally prepared to install VMware, I am familiar with this, but I did not dare to install such a large header because of poor computer configuration. So I decided to build another path. Considering the Windows system, the integration of Microsoft's own things is better, as a result, Microsoft virtualpc (VPC) 2007 was chosen. To be honest, it is very convenient for VPC to install Microsoft's own Windows system, but it is hard to install a Linux system.
As for how to install it, there are a bunch of tutorials on the Internet, so I will not talk much about it. Next I will talk a few more words about network configuration. On the VPC network configuration page, select the first network adapter that can access the Internet and set a local only. Here, a wireless network adapter is available:
Make sure that the VPC virtual service is installed and the following check box is selected:
Log on to centos 6.0 as the root user. Many friends may find that the network cannot be accessed, whether it is wget or ping. ifconfig is used to find that the eth0 Nic does not have IP addresses and other related configurations.
The following operations are performed as root with the highest permission.
You can use the following command to obtain the dynamic address from DHCP:
Or you can assign a static address as follows:
1 |
ifconfig eth0 192.168.1.4 netmask 255.255.255.0 |
After configuring the IP address and so on, we also need to set the gateway. The command for setting the gateway is as follows. Here, the gateway is 192.168.1.1. Before setting the gateway, You can ping it in centos to see if it can be pinged.
1 |
route add default gw 192.168.1.1 |
Run the following two commands to restart the NIC:
12345 |
Ifconfig eth0 downifconfig eth0 up # Or: # ifdown eth0 # IFUP eth0 |
Now, your centos should be able to access the Internet. Ping or wget.
Commands such as route add can only be valid in the current environment. After the virtual machine is restarted, the related configurations will be lost again. In this way, we need to perform gateway configuration and other operations, which is inconvenient, in fact, we can solve this problem through the following two methods:
- 1. Write to/etc/rc. Local. This is a link file, actually pointing to/etc/rc. d/rc. Local.
1 |
route add default gw 192.168.1.1 |
- 2. Write it to the NIC configuration file. Remember to review the VI editor command first.
123 |
VI/etc/sysconfig/network-scripts/ifcfg-eth0 # Add the following sentence gateway = 192.168.1.1 |