LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 629|回复: 2

先安装kvm,但是看不太懂

[复制链接]
发表于 2009-10-26 20:08:46 | 显示全部楼层 |阅读模式
参考的文章是http://en.gentoo-wiki.com/wiki/KVM
本人英文不好,看的真吃力,尤其是网络那块看的一沓糊涂,情赐教啊:
[edit] Enabling the access to Internet
The most transparent option to allow your guests access to the internet is the "virtual hub". In this scheme, the bridge connects eth0 and your tuntap interfaces together, routing packets as if it were a real "old fashioned" hub (not a switch). The key to this approach is to make sure you have unique mac addresses on both the host's tuntap interface as well as the guest. The guest ip addresses are typically in the same subnet as the host, and they can ask for and receive a dhcp lease from the same dhcp server that the host might use if it used dhcp. That is because all arp traffic and other broadcasts are passed through the bridge between the eth0 interface and the guest taps. The guests can use the same default gateway as the host because of this transparent passage.

The following snippet from an /etc/conf.d/net file shows the setup of a bridge between eth0 and two tap devices for guests. Note that the dependency for eth0 is left out of the br0 config since it is always started earlier on this particular system

1、上面这段话tuntap interfaces是什么东西啊,是属于客户机上的吗?
2、The key to this approach is to make sure you have unique mac addresses on both the host's tuntap interface as well as the guest
这句话是什么意思啊,是说主机的tuntap接口和客户机的tuntap接口拥有唯一的MAC地址,怎么个唯一法啊。
3、Note that their nic definitions on the kvm command line use different mac addresses than what is set for their taps. If the same mac address had been used on both sides, the arp queries for address resolution would not work. This conf.d/net setup is also why the kvm command line says not to do anything about interface startup or takedown.这句话是什么意思,谁给翻译一下啊
4、The changes in /etc/sysctl.conf are to prevent the traffic from the guests to be sent to iptables to be filtered。If you want to filter the traffic from/to the guests, you can keep the file unchanged but you will have to add the correct rules to iptables. The addition needed in /etc/sysctl.conf is ... 这句话也没看懂啊
最后还是想问问这里的网络连接是不是就是桥接,固定i难到没别的连接网络的方法了吗,我记得安装virtualbox的时候发现安装好操作系统可以直接上网了,这个咋这么费事呢
还有下面这个配置文件时针对固定ip地址的:
File: /etc/conf.d/net
bridge_br0="eth0 tap0 tap1"
brctl_br0=( "setfd 0" "sethello 0" "stp off" )
RC_NEED_br0="net.tap0 net.tap1"
#
#  host system is a static address at 192.168.1.12 with dns server at 34 and a router at 33
#
config_br0=( "192.168.1.12/24" )
routes_br0=( "default via 192.168.1.33" )
dns_domain_br0="example.com"
dns_servers_br0="192.168.1.34"
dns_search_br0="example.com"

config_tap0=( "null" )
tuntap_tap0="tap"
tunctl_tap0="-u joeuser"
mac_tap0="52:54:00:12:34:56"

config_tap1=( "null" )
tuntap_tap1="tap"
tunctl_tap1="-u joeuser"
mac_tap1="52:54:00:12:34:59"
config_eth0=( "null" )
要是ip地址不固定该怎样设置呢
发表于 2009-10-26 23:34:03 | 显示全部楼层
我覺得WIKI的方法不太好,你可以試試我的方法........
/etc/conf.d/net
  1. config_eth0=( "null" )
  2. bridge_br0="eth0"
  3. brctl_br0=( "stp on" )
  4. config_br0=( "192.168.1.4/24" )
复制代码

/etc/init.d/kvm
  1. #!/sbin/runscript
  2. # Copyright 1999-2008 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: $
  5. depend() {
  6.         need net
  7. }
  8. start() {
  9.         ebegin "Loading the kvm module"
  10.         /sbin/modprobe kvm
  11.         eend $? "Failed to load the kvm module"
  12.         ebegin "Loading the kvm_amd module"
  13.         /sbin/modprobe kvm_amd
  14.         eend $? "Failed to load the kvm_amd module"
  15.         eend 0
  16. }
  17. stop() {
  18.         ebegin "Unloading the kvm_amd module"
  19.         /sbin/modprobe -r kvm_amd
  20.         eend $? "Failed to unload the kvm_amd module"
  21.         ebegin "Unloading the kvm module"
  22.         /sbin/modprobe -r kvm
  23.         eend $? "Failed to unload the kvm module"
  24.         eend 0
  25. }
复制代码

/etc/kvm/kvm-ifup
  1. #!/bin/sh
  2. /sbin/brctl addif br0 $1
  3. if [ $? ]; then
  4.     logger -t kvm "Linking the bridge interface with $1"
  5. else
  6.     logger -t kvm "Failed to link the bridge interface with $1"
  7. fi
  8. /sbin/ifconfig $1 up 0.0.0.0 promisc
  9. if [ $? ]; then
  10.     logger -t kvm "Bring $1 interface up"
  11. else
  12.     logger -t kvm "Failed to bring $1 interface up"
  13. fi
复制代码

/etc/kvm/kvm-ifdown
  1. #!/bin/sh
  2. /sbin/ifconfig $1 down
  3. if [ $? ]; then
  4.     logger -t kvm "Bring $1 interface down"
  5. else
  6.     logger -t kvm "Failed to bring $1 interface down"
  7. fi
  8. /sbin/brctl delif br0 $1
  9. if [ $? ]; then
  10.     logger -t kvm "Unlinking the bridge interface with $1"
  11. else
  12.     logger -t kvm "Failed to Unlink the bridge interface with $1"
  13. fi
复制代码

script
  1. kvm -hda /etc/kvm/vm/Windows\ XP/hd0.img -m 1024 -usb -usbdevice tablet \
  2. -name winxp -vnc :1 -localtime -net nic,macaddr=00:1B:21:40:3A:5A -net tap -daemonize \
  3. 1>1.log 2>2.log
复制代码
回复 支持 反对

使用道具 举报

发表于 2009-10-26 23:53:40 | 显示全部楼层
可以去ubuntu中文论坛搜一下,我记得有两篇很简明的关于kvm桥接的帖子
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表