您的問題的詳細資訊是什麼?
你好,這是我第一次嘗試ovs。我正在使用 Arch Linux,並安裝了 openvswitch。
使用sudo ip link add v1 type dummy && sudo ip addr add 10.0.0.1/24 dev v1 && sudo ip link set v1 up
已建立的v1、v2(10.0.0.2/24)、v3(10.0.0.3/24)三塊虛擬網路卡。
將 v1 v2 v3 加到 ovs 中sudo ovs-vsctl add-port ovsbridge $NETCARDNAME
。
新增流規則sudo ovs-ofctl add-flow ovsbridge in_port=4,actions=output:5
(ovs 連接埠 4 是 v1 網路卡,ovs 連接埠 5 是 v2 網路卡)。透過檢查sudo ovs-ofctl show ovsbridge
現在,我使用python-scapy
將套件傳送到 v1 網路卡,並使用tcpdump -i INTERFACE_NAME -w tcpdump_output -vnnl
catch v1 v2 套件 nums。 v1 收到 10 個包裹,但 v2 收到 0 個包裹。
你嘗試了什麼
# start ovs by systemd
$ sudo ovs-vsctl add-br ovsbridge
$ sudo ovs-vsctl show
7194d04a-66aa-48c2-bfa4-99bbdc6fc4b2
Bridge ovsbridge
Port ovsbridge
Interface ovsbridge
type: internal
$ ip a # part of
8: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 3e:9a:4c:83:04:43 brd ff:ff:ff:ff:ff:ff
9: ovsbridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether 96:35:f1:d2:6b:46 brd ff:ff:ff:ff:ff:ff
$ sudo ip link add v1 type dummy
$ sudo ip addr add 10.0.0.1/24 dev v1
$ sudo ip link set v1 up
# and same to v2 v3
# add them to ovs
$ sudo ovs-vsctl add-port ovsbridge v1
$ sudo ovs-vsctl show
7194d04a-66aa-48c2-bfa4-99bbdc6fc4b2
Bridge ovsbridge
Port ovsbridge
Interface ovsbridge
type: internal
Port v3
Interface v3
Port v2
Interface v2
Port v1
Interface v1
$ ip a # part of
38: v1: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
link/ether da:11:b3:77:37:54 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.1/24 scope global v1
valid_lft forever preferred_lft forever
inet6 fe80::d811:b3ff:fe77:3754/64 scope link
valid_lft forever preferred_lft forever
39: v2: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
link/ether ca:06:56:9c:af:6d brd ff:ff:ff:ff:ff:ff
inet 10.0.0.2/24 scope global v2
valid_lft forever preferred_lft forever
inet6 fe80::c806:56ff:fe9c:af6d/64 scope link
valid_lft forever preferred_lft forever
40: v3: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue master ovs-system state UNKNOWN group default qlen 1000
link/ether 82:a4:e7:b0:e0:71 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.3/24 scope global v3
valid_lft forever preferred_lft forever
inet6 fe80::80a4:e7ff:feb0:e071/64 scope link
valid_lft forever preferred_lft forever
# add flow try forward v1 to v2
$ sudo ovs-ofctl add-flow ovsbridge in_port=4,actions=output:5
# check flow rule
$ sudo ovs-ofctl dump-flows ovsbridge
cookie=0x0, duration=1138.852s, table=0, n_packets=0, n_bytes=0, in_port=v1 actions=output:v2
cookie=0x0, duration=32571.512s, table=0, n_packets=518, n_bytes=177156, priority=0 actions=NORMAL
$ sudo ovs-appctl fdb/show ovsbridge
port VLAN MAC Age
LOCAL 0 a8:7e:ea:be:07:e4 278
$ cat rnd_pkt.py # part of
scapy.sendp(get_random_packet(), iface=v1)
# send 10 packages to v1
並且sudo ovs-tcpdump -i v1
不顯示我透過 scapy 發送的包裹。我在想也許我不應該使用 python-scapy 進行測試?
你在期待什麼?
我希望 ovs 會將軟體包從 v1 複製到 v2。
如果你們需要更多信息,請告訴我。 :)
答案1
用於ip link set $NETCARD promisc on
啟用混雜模式,且運作正常。