Comprehensive network settings for VMware and Qemu virtual machines
Source: Internet
Author: User
Article title: comprehensive network settings for VMware and Qemu virtual machines. Linux is a technology channel of the IT lab in China. Includes desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic classification Qemu Internet access methods:
User mode network:
It is very easy to implement virtual machine Internet access in this way, similar to nat in VMware. when qemu is started, The-user-net parameter is added. The virtual machine can communicate with the Internet through dhcp, however, the communication between the VM and the host is inconvenient.
Tap/tun network:
This method is more complex than the user mode, but after the virtual machine is set, the VM <--> Internet virtual machine <--> host communication is easy.
This method is similar to VMware's host-only. qemu uses the tun/tap device to add a virtual network device (tun0) to the host, and then you can configure it like a real Nic.
First, the kernel supports the tap/tuns device:
Device Drivers --->
Networking support --->
[M] Universal TUN/TAP device driver support
If the current kernel does not support this function, you can recompile and add only the corresponding modules. the method is simple:
Run the current kernel configuration file cp under the kernel source code directory:
[Root @ LFS net] # lsmod | grep tun
Tun 8704 0
[Root @ LFS net] #
OK. The entire kernel is not re-compiled and added to the support of special modules.
If your xx card is not supported by the kernel and can be compiled into modules, you can use this method to compile only the modules you need if you are afraid of a problem after re-compiling the kernel, then manually install it to the corresponding location and then load it.
In this way, the compilation speed is faster than that of the entire kernel. without any damage to the system, you can use the XX card. Pai_^
Note the following three points:
1. the source code of the kernel must be exactly the same as that of the current kernel version. Otherwise, the compiled modules cannot be used.
2. Note that only make modules (compilation module) does not have make modules_install (the module is automatically installed under/lib/modules)
3. run depmod before loading the newly compiled module. otherwise, modprobe cannot find it.
In fact, you can use the current kernel configuration file (/boot/config-[kernel-version]) to add only the modules you need without making any changes. make modules_install should not be faulty.
However, the safest way is to install it manually. the control is more reliable in your own hands :-)
OK, go back to qemu for Internet access
If you use udev to manage devices (udev is usually used in 2.6.x kernel releases), after modprobe tun, the/dev/net directory is automatically created and the tun device is created, link:
Then, you can grant the qemu-ifup x execution permission under/etc.
This script can only be executed by the root user. to use qemu for normal users, you need to change it to sudo/sbin/ifconfig... and then set sudo-related permissions.
After qemu is started, it adds a virtual network device (tun0) to the host ):
Similar to host-only, in this way, only virtual machines <----> can communicate with each other. you also need to set a router to enable nat to connect to the Internet.
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.