Virtualization

./pox.py log.level –DEBUG forwarding.l2_learning 未按預期工作

  • June 22, 2013

我已經在執行 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 控制器以連接到我的主機 PC,如下所示。

./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 地址。我似乎沒有得到那個。難道我做錯了什麼?

我認為您失去了 POX 的綁定地址和埠。您可以嘗試使用以下命令:

./pox.py log.level --DEBUG forwarding.l2_learning --address=**your_address** --port=6633

引用自:https://serverfault.com/questions/497789