Chinaunix首页 | 论坛 | 博客
  • 博客访问: 176051
  • 博文数量: 29
  • 博客积分: 2110
  • 博客等级: 大尉
  • 技术积分: 325
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-01 11:32
文章分类

全部博文(29)

文章存档

2012年(3)

2010年(4)

2009年(5)

2007年(16)

2006年(1)

我的朋友

分类: LINUX

2010-09-09 16:37:08

1.         创建网桥

[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

2.         创建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

3.         vlan加入到网桥中

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

4.         创建端口配置文件

[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 

阅读(2010) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~