目录
一、理论
1.Linux Bridge
二、实验
1.LBR 网桥管理
三、问题
1.Linux虚拟交换机如何增删
一、理论
1.Linux Bridge
Linux Bridge(网桥)是用纯软件实现的虚拟交换机,有着和物理交换机相同的功能,例如二层交换,MAC地址学习等。因此我们可以把tun/tap,veth pair等设备绑定到网桥上,就像是把设备连接到物理交换机上一样。此外它和veth pair、tun/tap一样,也是一种虚拟网络设备,具有虚拟设备的所有特性,例如配置IP,MAC地址等。
Linux Bridge通常是搭配KVM、docker等虚拟化技术一起使用的,用于构建虚拟网络。
二、实验
1.LBR 网桥管理
(1) SUSE系统用WinSCP拷贝轻量镜像TinyCore-11.0.iso
(2)准备安装
(3)任意选一个
(4)弹出配置界面
(5)修改虚拟机名称
(6)查看硬件
(7)查看宿主机设备
(8)外部设备Cirrus为图形化设备
(9)磁盘存放目录
(10)进入编辑界面
(11)协议支持多种格式
(12)修改协议
(13)网络适配器
(14)编辑页面,查看类型为半虚拟化设备
(15)也有全虚拟化设备可以选择
(16)这里选择全虚拟化并指定网桥br0
(17)选择apply.
(18)选择挂载光驱
(19)选择apply
(20)点击ok
(21)选择第3个
(22)进入TinyCore系统查看所有网卡
(23)TinyCore系统指定网卡
(24)SUSE系统网桥已新增虚拟端口vnet0
SUSE:~ # brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29a7aa24 no eth0
vnet0
br1 8000.000000000000 no
(25)SUSE系统查看虚拟网卡
SUSE:~ # ip add show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
inet 127.0.0.2/8 brd 127.255.255.255 scope host secondary lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP qlen 1000
link/ether 00:0c:29:a7:aa:24 brd ff:ff:ff:ff:ff:ff
inet6 fe80::20c:29ff:fea7:aa24/64 scope link
valid_lft forever preferred_lft forever
7: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:0c:29:a7:aa:24 brd ff:ff:ff:ff:ff:ff
inet 192.168.204.133/24 brd 192.168.204.255 scope global br0
inet6 fe80::20c:29ff:fea7:aa24/64 scope link
valid_lft forever preferred_lft forever
10: br1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
link/ether c6:f2:b3:25:18:90 brd ff:ff:ff:ff:ff:ff
11: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 500
link/ether fe:54:00:01:3c:53 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fe01:3c53/64 scope link
valid_lft forever preferred_lft forever
(26)brctl帮助命令
SUSE:~ # brctl --help
Usage: brctl [commands]
commands:
addbr <bridge> add bridge
delbr <bridge> delete bridge
addif <bridge> <device> add interface to bridge
delif <bridge> <device> delete interface from bridge
setageing <bridge> <time> set ageing time
setbridgeprio <bridge> <prio> set bridge priority
setfd <bridge> <time> set bridge forward delay
sethello <bridge> <time> set hello time
setmaxage <bridge> <time> set max message age
setpathcost <bridge> <port> <cost> set path cost
setportprio <bridge> <port> <prio> set port priority
show [ <bridge> ] show a list of bridges
showmacs <bridge> show a list of mac addrs
showstp <bridge> show bridge stp info
stp <bridge> {on|off} turn stp on/off
(27)2口取到MAC地址
SUSE:~ # brctl showmacs br0
port no mac addr is local? ageing timer
1 00:0c:29:74:e7:ff no 8.08
1 00:0c:29:a7:aa:24 yes 0.00
1 00:50:56:c0:00:08 no 0.00
1 00:50:56:e4:32:85 no 284.00
2 fe:54:00:01:3c:53 yes 0.00
(28)查看TinyCore网卡,TinyCore的eth0虚拟网卡已与宿主机SUSE的vnet0虚拟端口实现绑定
三、问题
1.Linux虚拟交换机如何增删
(1)查看Linux Bridge信息
SUSE:~ # brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29a7aa24 no eth0
(2)添加虚拟交换机
SUSE:~ # brctl addbr br1
SUSE:~ # brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29a7aa24 no eth0
br1 8000.000000000000 no
(3)删除虚拟交换机
SUSE:~ # brctl delbr br1
SUSE:~ # brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000c29a7aa24 no eth0