首页 > 虚拟化 > xen networking
您的足迹
  • 你没有浏览过任何文章或者你没有开启cookies。

xen networking

一、一台Pc server  OS CentOS 5.3

二、实验原理

[网桥]是用于连接ISO第二层网络的设备,它只提供以太网层次的连接,对于之上的TCP/IP等协议来说是完全透明的,你可以

把它理解为交换机,实际上交换机也是一种网桥的实现。在Linux上配置网桥可以说就是把机器当作交换机来用。

三、安装配置

1. [root@localhost ~]# rpm -qa |grep bridge-utils

bridge-utils-1.1-2

装好以后,bridge-utils工具包就可以使用了

2. 创建网桥

[root@localhost ~]# brctl addbr xenvbr11

[root@localhost ~]# brctl stp xenvbr11 off

[root@localhost ~]# brctl setfd xenvbr11 0 //set forward delay time

[root@localhost ~]# ip link set xenvbr11 up

3. 创建vlan

[root@localhost ~]# vconfig set_name_type DEV_PLUS_VID_NO_PAD

[root@localhost ~]#vconfig add peth0 11 //在peth0上创建vlan

[root@localhost ~]# ip link set peth0.11  address fe:ff:ff:ff:ff:ff

[root@localhost ~]# ip link set peth0.11 up

4. 把vlan加入到网桥中

[root@localhost ~]# brctl addif xenvbr11 peth0.11

5. 创建端口配置文件

[root@localhost ~]#  cd /etc/sysconfig/network-scripts/

[root@localhost network-scripts]# cat ifcfg-peth0.11

       DEVICE=peth0.11
        TYPE=Ethernet
        ONBOOT=yes
        MACADDR=fe:ff:ff:ff:ff:ff
        VLAN=yes
        IPADDR=192.168.5.1
        NETMASK=255.255.255.0
        VLAN_NAME_TYPE=DEV_PLUS_VID_NO_PAD
        BRIDGE=xenvbr11

[root@localhost network-scripts]# cat ifcfg-xenvbr11

       DEVICE=xenvbr11
        TYPE=Bridge
        DELAY=0
        STP=off
        ONBOOT=yes

[root@localhost ~]# cat /etc/init.d/xenvlansetup

       #!/bin/bash
        #
        # xenvlansetup   Script to start and stop the Xen vlan .
        #
        #
        # chkconfig: 2345 98 02
        # description: Starts and stops the Xen vlan.

        # Source function library.
        . /etc/rc.d/init.d/functions

        RETVAL=0

        case "$1" in
          start)
                xenbridge=`brctl show | grep xenvbr | awk '($4 == ""){print $1}' 2>&1`
                for bridge in $xenbridge
                do
                    device="peth0"
                    vlanId=${bridge:6}
                    vlanDevice="peth0.${vlanId}"

                    vconfig add $device $vlanId 2>&1
                    ip link set $vlanDevice address fe:ff:ff:ff:ff:ff 2>&1
                    ip link set $vlanDevice up 2>&1
                    brctl addif $bridge $vlanDevice 2>&1
                done
                ;;
          stop)
                ;;
          status)
                ;;
          *)
                exit 1
        esac

        exit $RETVAL

[root@localhost ~]# chmod +x /etc/init.d/xenvlansetup
[root@localhost ~]# chkconfig –add xenvlansetup
6.创建虚拟机test 和test2,配置文件如下
[root@localhost ~]# cat /etc/xen/test

       name = "test"
        uuid = "d13eb7de-c77b-7b25-c221-ac03c1f39104"
        maxmem = 512
        memory = 512
        vcpus = 1
        bootloader = "/usr/bin/pygrub"
        on_poweroff = "destroy"
        on_reboot = "restart"
        on_crash = "restart"
        vfb = [ "type=vnc,vncunused=1,keymap=en-us" ]
        disk = [ "tap:aio:/var/lib/xen/images/test.img,xvda,w" ]
        vif = [ "mac=00:16:3e:02:cb:38,bridge=xenbr0" ]

[root@localhost ~]# cat /etc/xen/test2

       name = "test2"
        uuid = "8c965e6e-d844-6c05-dadd-1156352842c2"
        maxmem = 512
        memory = 512
        vcpus = 1
        bootloader = "/usr/bin/pygrub"
        on_poweroff = "destroy"
        on_reboot = "restart"
        on_crash = "restart"
        vfb = [ "type=vnc,vncunused=1,keymap=en-us" ]
        disk = [ "tap:aio:/var/lib/xen/images/test2-1.img,xvda,w" ]
        vif = [ "mac=00:16:3e:31:0b:d3,bridge=xenbr0" ]

在两台虚拟机设置ip 分别为192.168.5.42和192.168.5.45
现在登上其中 一台,测试能否ping 通
[root@localhost ~]# ping 192.168.5.45
PING 192.168.5.45 (192.168.5.45) 56(84) bytes of data.
64 bytes from 192.168.5.45: icmp_seq=1 ttl=64 time=0.238 ms
64 bytes from 192.168.5.45: icmp_seq=2 ttl=64 time=0.169 ms
64 bytes from 192.168.5.45: icmp_seq=3 ttl=64 time=0.170 ms

— 192.168.5.45 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.169/0.192/0.238/0.034 ms
[root@localhost ~]#
在上面实验中两台虚拟机加入同默认网桥,如果加入新建的vlan 中,两台虚拟机间可以ping通,但由于和物理不在同一vlan中,所以ping 不通。如果不同的vlan之间要通需要在交换机上设置。
此次实验还碰到一个问题,就是xm console 不能访问的问题,这个问题解决如下:
(1)Connect this guest using ssh if you know the guest OS ip address.
(2) Use vncviewer to connect to this guest from VmServer.#vncviewer :59005900 is the first port default.
(3) Refer to note:579413.1 to create a console to connect to your guest from VmServer (as a workaround) . this is snippet from this note.=============================================For PVM, please do as following:1, Boot the Dom-U2, add the following lines before the first “title …” line in the /etc/grub.conf file:console=tty console=xvc03, add the following line to /etc/inittabco:2345:respawn:/sbin/agetty xvc0 9600 vt100-nav4, add “xvc0″ to /etc/securettyAfter doing above configuration on Dom-U, please reboot the Dom-U and have a try to connect the guest console.
原文地址如下:http://forums.oracle.com/forums/thread.jspa?messageID=2684783
四、此次实验此结束

  1. 还没有评论
评论提交中, 请稍候...

留言

可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackbacks & Pingbacks ( 0 )
  1. 还没有 trackbacks
Feed