您的问题的具体细节是什么?
嗨,这是我第一次尝试 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
捕获 v1 v2 包数量。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
启用混杂模式,并且工作正常。