我已经在运行 Ubuntu 12.04 的 PC 上安装了 openvswitch。我的 PC 上还运行着虚拟盒,其中运行着 3 个虚拟机(Ubuntu 12.04)。它们被命名为
vm-1
vm-2
vm-3
我已经在主机上配置了 openvswitch,如下所示。
sudo ovs-vsctl show
#Create the virtual switch on the host machine
sudo ovs-vsctl add-br lan0
#Next we create tap devices on the host machine so we can bind them to the guests VM's later.
for tap in `seq 1 5`; do
sudo ip tuntap add mode tap lan0-p$tap
done;
#check if the interfaces are there
ip tuntap list
#Bring up the tap interfaces.
for tap in `seq 1 5`; do
sudo ip link set lan0-p$tap up
done;
# check if the interface are up
ip link
#Now we use ovs-vsctl to "bind" the tap devices to "lan0" switch
for tap in `seq 1 5`; do
sudo ovs-vsctl add-port lan0 lan0-p$tap
done;
#see that the tap devices are mapped to ports in lan0
sudo ovs-vsctl list-ports lan0
在主机上执行此操作后ifconfig的输出如下。
eth0 Link encap:Ethernet HWaddr 1c:6f:65:37:60:b5
inet addr:192.168.129.56 Bcast:192.168.129.255 Mask:255.255.254.0
inet6 addr: fe80::1e6f:65ff:fe37:60b5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:44955 errors:0 dropped:0 overruns:0 frame:0
TX packets:10042 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:13293545 (13.2 MB) TX bytes:1978326 (1.9 MB)
Interrupt:54 Base address:0x8000
lan0-p1 Link encap:Ethernet HWaddr 56:66:06:2d:da:ee
inet6 addr: fe80::5466:6ff:fe2d:daee/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:676 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lan0-p2 Link encap:Ethernet HWaddr 06:25:a2:ad:85:58
inet6 addr: fe80::425:a2ff:fead:8558/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:676 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lan0-p3 Link encap:Ethernet HWaddr 52:8e:34:67:a0:40
inet6 addr: fe80::508e:34ff:fe67:a040/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:676 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lan0-p4 Link encap:Ethernet HWaddr 22:6e:e8:62:c5:e8
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lan0-p5 Link encap:Ethernet HWaddr de:6f:9d:f9:c9:45
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:64 errors:0 dropped:0 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4984 (4.9 KB) TX bytes:4984 (4.9 KB)
现在使用在“桥接适配器”中配置的每个虚拟机上的网络设置
vm-1 is attached to lan0-p1
vm-2 is attached to lan0-p2
vm-3 is attached to lan0-p3
我已经安装了在我的主机电脑上运行的 pox 控制器。我运行 pox 控制器以连接到我的主机电脑,如下所示。
./pox.py log.level --DEBUG forwarding.l2_learning
我得到的输出如下
POX 0.1.0 (betta) / Copyright 2011-2013 James McCauley, et al.
DEBUG:core:POX 0.1.0 (betta) going up...
DEBUG:core:Running on CPython (2.7.3/Aug 1 2012 05:14:39)
DEBUG:core:Platform is Linux-3.2.0-38-generic-x86_64-with-Ubuntu-12.04-precise
INFO:core:POX 0.1.0 (betta) is up.
DEBUG:openflow.of_01:Listening on 0.0.0.0:6633
It shows listening on 0.0.0.0:6633 ? What is 0.0.0.0 ?
我期望输出如下
INFO:openflow.of_01:[Con 1/1] Connected to 00-00-00-00-00-01
DEBUG:forwarding.l2_learning:Connection [Con 1/1]
DEBUG:forwarding.l2_learning:installing flow for 00:00:00:00:00:03.2 ->
00:00:00:00:00:02.1
DEBUG:forwarding.l2_learning:installing flow for 00:00:00:00:00:02.1 ->
00:00:00:00:00:03.2
DEBUG:forwarding.l2_learning:installing flow for 00:00:00:00:00:03.2 ->
00:00:00:00:00:02.1
DEBUG:forwarding.l2_learning:installing flow for 00:00:00:00:00:04.3 ->
00:00:00:00:00:02.1
DEBUG:forwarding.l2_learning:installing flow for 00:00:00:00:00:02.1 ->
00:00:00:00:00:04.3
或者类似的东西,表明它正在学习不同的 MAC 地址。我似乎不明白。我做错了什么吗?
答案1
我认为您丢失了 POX 的绑定地址和端口。您可以尝试使用以下命令:
./pox.py log.level --DEBUG forwarding.l2_learning --address=**your_address** --port=6633