If your XXX card is not supported by the kernel, and you fear that your own compiled kernel will cause system damage, you can try this method ^_^
VMware Three network connection Internet settings:
Default Use Vmnet0
The IP settings of the virtual machine are not used with the host network segment and the rest are the same as the host:
For example, host IP is 10.70.54.31, set virtual machine IP to 10.70.54.22. Netmask,broadcast,gateway,dns is the same as the host to achieve the virtual machine <---> Host virtual machine <----> Internet communications.
Default Use Vmnet8
Set up the virtual machine to use DHCP to access the Internet, Windows Select "Automatically get IP", Linux to open the DHCP service can
You can also manually set:
IP settings and vmnet8 with the network segment, gateway set into VMNET8 Gateway (/etc/vmware/vmnet8/nat/nat.conf) can be found in the gateway Vmnet8, usually xxx.xxx.xxx.2.
The Netmask,broadcast setting is the same as VMNET8, and the DNS settings are the same as the host.
such as Vmnet8 ip:172.16.249.1 gw:172.16.249.2
Virtual machine settings: ip:172.16.249.100 gw:172.16.249.2
Default Use Vmnet1
The virtual machine IP settings and Vmnet1 with the network segment, gateway set to Vmnet1 IP, the rest of the same settings and Vmnet1, DNS settings and host the same
such as Vmnet1 ip:172.16.245.1
Virtual machine settings: ip:172.16.245.100 gateway:172.16.245.1
This enables the virtual machine <---> host communication, but the virtual machine <---> The Internet is still unable to communicate
Virtual machine and Internet communication:
1. Open Host Routing function
2. Set the iptables, make the host become a NAT server
1. Echo 1 >/proc/sys/net/ipv4/ip_forward This allows the host to have the routing function
2. Iptables-t nat-a postrouting-o eth0-s 172.16.245.0/24-j Masquerade
This rule means that the source IP from the 172.16.245.0/24 packet is disguised as eth0 IP, and the virtual machine communicates with the Internet.
If the network interface is ppp+ or PPPoE, it needs to be modified to-o PPPoE
Of course, S 172.16.245.0/24 also need to modify according to the actual situation
QEMU two ways to access the Internet:
User Mode network:
This way to achieve a virtual machine online is very simple, similar to the VMware Nat,qemu startup when the-user-net parameters, virtual machines using DHCP, you can communicate with the Internet, but this way the virtual machine and host communication is not convenient.
This is a bit more complicated than user mode, but it's easy to set up a virtual machine <--> an Internet virtual machine <--> host communication.
This way, a host-only,qemu like VMware is set up to use the TUN/TAP device to add a virtual network device (TUN0) to the host, and then configure it like a real network card.
First, tap/tuns devices are supported in the kernel:
[M] Universal Tun/tap device driver Support
If the current kernel does not support it, you can recompile the module by adding it simply:
The current kernel profile CP to the kernel source directory:
[Root@lfs ~] #cp/boot/config-[kernel-version]/usr/src/linux
[Root@lfs ~] #cd/usr/src/linux
Configure the kernel to select the Tun/tap module (M) as shown above:
[Root@lfs ~] #make menuconfig
Re-compile only module (M), do not compile core (*) supported Dongdong:
[Root@lfs ~] #make Modules
After compiling, the Tun.ko can be found under/usr/src/linux/drivers/net:
[Root@lfs NET] #ls-L/usr/src/linux/drivers/net/tun.ko
-rw-r--r--1 root root 11116 Mar 20:29/usr/src/linux/drivers/net/tun.ko
It is CP to the current kernel's module directory at the appropriate location:
[Root@lfs NET] #cp/usr/src/linux/drivers/net/tun.ko/lib/modules/' uname-r '/kernel/drivers/net
To re-establish a module dependency:
[Root@lfs NET] #depmod
Now it's ready to load:
[Root@lfs NET] #modprobe Tun
[Root@lfs NET] #lsmod |grep Tun
Tun 8704 0
Ok. Success does not recompile the entire kernel join special module support
If your XX card is not supported by the kernel, you can compile into a module, you are afraid of recompiling the kernel after the problem can be used to compile only the module you need, and then manually install to the appropriate location, and then load it.
This compiles the speed to also be quicker than compiles the entire kernel, does not have any damage to the system, may use on the XX card. ^_^
Pay attention to three points:
1. Kernel source code must be exactly the same as the current kernel version, otherwise the compiled module is not available.
2. Note Only make modules (compiled module), no make Modules_install (automatic installation module to/lib/modules)
3. You must run Depmod before loading the newly compiled module, otherwise modprobe cannot find it
In fact, using the current kernel configuration file (/boot/config-[kernel-version]), only to add the modules you need, do not do any other changes, make modules_install should not have problems.
But the safest way is to manually install it, control in their own hands more down-to-earth:-)
OK, back to qemu Internet problem
If you use a Udev management device (typically the distribution of the 2.6.x kernel already uses udev), the/dev/net directory is automatically created after Modprobe Tun, and the Tun device is built to do the relevant linking:
[Root@lfs NET] #ls-L/dev/net/tun
lrwxrwxrwx 1 root 6 15:35/dev/net/tun->. /tun
If it's unfortunate, you don't see it, you need to do the work yourself manually.
[Root@lfs ~] #mkdir/dev/net
[Root@lfs ~] #mknod/dev/net/tun c 10 200
OK, the related device is ready and you need a TUN/TAP initialization script:
Then give Qemu-ifup x Execute permission to put it under/etc.
This script can only be executed by the root user, and if you need to use QEMU for the average user, you need to change to sudo/sbin/ifconfig ... Then set sudo related permissions.
When QEMU is started, it adds a virtual network device (TUN0) to the host:
[Root@lfs ~] #ifconfig tun0
Tun0 Link encap:ethernet hwaddr 0A3:8A:5D:97:CD
inet addr:172.20.0.1 bcast:172.20.255.255 mask:255.255.0.0
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
You can now start Qemu to configure the virtual machine network parameters, just like VMware host-only:
IP and tun0 the same network segment, Gateway for tun0 IP remaining parameters and tun0 the same, DNS and host the same:
tun0:ip:172.20.0.1 broadcast:172.20.255.255 netmask:255.255.0.0
qemu:ip:172.20.0.100 broadcast:172.20.255.255 netmask:255.255.0.0 gateway:172.20.0.1
Like Host-only, this only implements the virtual machine <----> communication between the hosts, but also need to set up Router,nat to connect to the Internet
[Root@lfs ~] #echo 1 >/proc/sys/net/ipv4/ip_forward
[Root@lfs ~] #iptables-t nat-a postrouting-o eth0-s 172.20.0.0/24-j Masquerade
OK, Virtual machine <---> Host virtual machine <----> Internet communication is complete.