Some time ago, I also learned a lot of network-related knowledge and passed various practices. But never start from scratch. I will try it out in a letter today. The following are detailed records of this process. This includes understanding of the network and recording of problems encountered. Practice and purpose: 1. bridge multiple linux virtual machines together. (If there is a physical host, the principle is the same .) 2. configure the network so that you can learn a lot of network-related knowledge between the virtual machine and the host, and between the virtual machine and the virtual machine, and also pass various practices. But never start from scratch. I will try it out in a letter today. The following are detailed records of this process. This includes understanding of the network and recording of problems encountered. Practice and purpose: 1. bridge multiple linux virtual machines together. (If there is a physical host, the principle is the same .) 2. configure a network to enable network communication between virtual machines and hosts, and between virtual machines. 3. virtual machines can access the Internet. (If you can ping www.baidu.com) you need to set the parameter: host ip address: 192.168.1.101 (the ip address is no longer configured by yourself and will not be dynamically allocated by dhcp. in the following operations, this step has been completed by default .) Virtual Machine 1 and virtual machine 2 are connected through a bridge and set to the same network segment as the host so that the host can communicate with each other. Virtual Machine 1IP: 192.168.1.11 virtual machine 2IP: 192.168.1.22 gateway address: 192.168.1.1 (this is the vro address. you can set the ip address of the gateway between the host and the virtual machine to access the Internet) I. environment preparation: In the virtualbox Virtual Machine Manager, a redhat operating system "Red_hat_32_vt" is installed ). Today, we cloned an identical virtual machine and named it "Red_hat_Second" (I wanted to change the previous virtual machine to Red_hat_First, but I couldn't change it). note: 1. here we use virtual machines to simulate real servers. After learning about the network and linux system, there is basically no difference between virtual machines and real physical hosts. 2. using vmware or kvm to install a virtual machine is the same. 3. the ip address in the physical host (windows) system is 192.168.1.101 4, and the ip address of the router is 192.168.1.1. the router here is a gateway connected to the intranet and internet. 2. setting the bridging mode is simple in virtual box and vmware. Kvm is not the same. But the principle is the same. 3. set the network. 1. check whether the virtual machine that has just been installed in the network configuration is the original network configuration. There is only one back-to-ring network card. You can see through the ifconifg command. 2. you can see from the above that only the back-to-ring network card is added. now you need to add a network card for subsequent network configuration and operations. If you do not add a Nic and configure the network, you will find that the Nic cannot communicate with the physical host. you can use the command line to add a Nic: # Add a Nic to the command line, set its ip address to 192.168.1.22ifconfig eth0 192.168.1.22 netmask 192.168.1.255, but add it on the command line temporarily. change the terminal environment or restart the server next time, this setting will become invalid. So now we want to add it from the preparation and add it permanently. In order to avoid interference with the subsequent preparation, first turn off the Nic added in the preceding command line mode. Ifconfig eth0 down add the Nic by adding the configuration: Enter the/etc/sysconfig/network-scripts/network configuration Directory. the ifcfg-switch configuration file is the network configuration corresponding to the NIC, you can add a new Nic eth0cp ifcfg-lo ifcfg-eth0 in a similar way first look at the preparation of the loopback Nic. I marked some information in red. According to the gourd painting, the ifcfg-eth0 into our desired preparation into what we need, 3, test the internal network restart network: service network restart and then another virtual machine in the same way, the ip address of another virtual machine is 192.168.1.11. now, the host and the two virtual machines are both in the same network segment, so they should be able to communicate with each other. Ping test: 4. set the external network to pass the previous settings. the host and the two virtual machines can communicate with each other. However, it seems that you cannot access the Internet. Ping www.baidu.com through the error message, you can find that the virtual machine does not know the domain name "www.baidu.com. Okay. Then let's prepare the DNS. configure the DNS: how to prepare the DNS. First, you can use windows to check how the dns is prepared on windows, and then configure it on linux. On my winddows machine: two methods for preparing DNS: The first method: through/etc/resolv. conf dns configuration file to enter the linux Virtual Machine vim/etc/resolv. conf: Edit the dns configuration file and add the following red lines to the backend: Note: The first two nameservers are the primary dns server and the second dns server. The second method: in the NIC preparation file ifcfg-eth0, add dns preparation note: add here, you need to restart the network Oh! All right, DNS has been configured. can I ping www.baidu.com and find that the DNS cannot be pinged. What's going on. Configure the Gateway: Check whether the dns settings are correct, or if you cannot ping www.baidu.com. now you can ping the host, virtual machine, and Gateway. Dns is also correctly configured. it is reasonable to say that you can access the Internet. However, there is another key step: configure the default gateway, which is not ready yet. If no default gateway is configured, how can we communicate with the outside world. Now let's configure the Gateway: There are two ways: first, use the command line for temporary configuration: add the default gateway on the command line: route add defalult gw 192.168.1.1 default gateway, this route (default gateway) is used when the corresponding route cannot be found, which is necessary for setting access to the Internet. In order not to affect the following steps, delete the Gateway prepared by the command line to delete the default gateway: route del default gw 192.168.1.1. Method 2: permanent configuration in the NIC configuration file, note the red part. After preparation, restart the network. Service network restart can now ping www.baidu.com, which means you can access the Internet. Now, this practice is over.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.