KVM Centos6 Windows 客户机无网络

KVM Centos6 Windows 客户机无网络

通过本指南在 KVM 上运行 Windows 2008 r2 虚拟。https://wiki.centos.org/HowTos/KVM#head-8424c473b52c407c62d08e8a37406821d05f5862

使用 virt-manager 提供的接口

使用设置:

在此处输入图片描述

Windows 网络适配器信息:

在此处输入图片描述

First you will need bridge-utils, available from the base repo:


yum install bridge-utils
You'll also need tunctl.

This is now available from the RPMForge repository, so, once the repo is enabled, can easily be installed with


yum install tunctl
You will also want to edit your /etc/udev/rules.d/90-kvm-rules. When you installed the rpm, the created file reads:


KERNEL=="kvm",          NAME="%k", GROUP="kvm", MODE="0660" 
In theory, adding the line:


KERNEL=="tun",          NAME="net/%k", GROUP="kvm", MODE="0660" 
should give /dev/net/tun proper permissions. In practice, this doesn't seem to be the case, and though it is a kludge, one can simply add lines like


chown root:kvm /dev/net/tun
chmod 0660 /dev/net/tun 
to /etc/rc.local. This will definitely work. If the reader only uses kvm on occasion, they can simply make a little script with those lines, save it as something like tunperms.sh (or a better name) and just run it, either as root or with root permissions, when you want to use bridged networking.

For the impatient, here is our simple script. We'll explain it afterwards. This is assuming that you're on a 192.168.1.0/24 network with no DHCP server.


#!/bin/sh
PATH=$PATH:/usr/sbin:/sbin
sudo brctl addbr br0
sudo ifconfig eth0 0.0.0.0
sudo brctl addif br0 eth0
sudo ifconfig br0 192.168.1.120 netmask 255.255.255.0 up
sudo route add -net 192.168.1.0 netmask 255.255.255.0 br0
sudo route add default gw 192.168.1.1 br0
sudo tunctl -b -u john
sudo ifconfig tap0 up
sudo brctl addif br0 tap0
export SDL_VIDEO_X11_DGAMOUSE=0
sudo iptables -I RH-Firewall-1-INPUT -i br0 -j ACCEPT
qemu-kvm ~/win2k.img -m 512 -net nic -net tap,ifname=tap0,script=no

根据上述指南,我做了所有事情,直到

sudo ifconfig br0 192.168.1.120 网络掩码 255.255.255.0 启动

这会关闭我的远程连接,并且很长时间内不执行任何操作,直到我重新启动服务器。它似乎只能成功断开服务器的连接。

无法获得互联网连接。

不确定如何设置连接。还查看了:

https://unix.stackexchange.com/questions/158077/no-internet-connection-for-a-kvm-guest-what-c​​ould-be-wrong

并运行以下命令:

iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535
iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.122.0/24 -o eth0 -j SNAT --to-source <my server 19 here>
iptables -t filters -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filters -A FORWARD -s 192.168.122.0/24 -i br0 -j ACCEPT
iptables -t filters -A INPUT -s 192.168.122.0/24 -i br0 -j ACCEPT

答案1

我重新映像了我的 centos。

然后重新安装 Windows。成功了。

相关内容