OVS Open vSwitch 基本操作 命令(1)

一、两种 OVS fallback behavior
1. standalone
这种模式下,没有运行controller的情况下,OVS会自动调回普通switch模式,如果有controller的情况,ovs会自动变成openflow switch
命令:
ovs-vsctl set-fail-mode ovs-switch standalone

ovs-switch替换成bridge的名字

2.secure
这种模式下,无论有没有controller, ovs都会作为openflow switch运行,也就是所有interface在bridge上,等待controller或者用户添加flow到switch来进行通信

ovs-vsctl set-fail-mode ovs-switch secure

二、 OVS常用的两个 command line tool
ovs-vsctl 用来查询和配置ovs-vswitchd
ovs-ofctl 管理配置openflow switch

1.显示bridge的信息,连接到bridge上的interface,tap和端口号(port)
ovs-ofctl show ovs-switch(ovs-switch代表bridge的名字,也就是虚拟的switch,下同)

2. 显示flow entries
ovs-ofctl dump-flows ovs-switch

3. 添加flow
ovs-ofctl add-flow ovs-switch"in_port=2,actions=output:8"
flow有很多syntax, 一半来说actions之前都是match的部分,常用的一般是

in_port: switch的端口
dl_src: 源mac地址
dl_dst:目的mac地址
dl_type:以太网协议类型 0x0806是arp packet 0x0800是ip packet
nw_src:源IP
nw_dst:目的ip
nw_proto:协议类型,注意和dl_type区分,同时也需要和dl_type一起使用,比如dl_type是ip(0x0800),那么nw_proto=1就表示icmppacket
tp_src: tcp udp源端口
tp_dst: tcp udp目的端口

 

ip

 

Same as dl_type=0x0800.

 
 

icmp

 

Same as dl_type=0x0800,nw_proto=1.

 
 

tcp

 

Same as dl_type=0x0800,nw_proto=6.

 
 

udp

 

Same as dl_type=0x0800,nw_proto=17.

 
 

arp

 

Same as dl_type=0x0806.

 
 

rarp

 

Same as dl_type=0x8035.



actions:

output:port
controller(key=value) 送到controller作为packet-in 消息,括号内的key valuepair可以是:
reason= reason reason 可以是action,no_match,invalid_ttl
id=controller-id 默认是0,特殊的controller会有一个16位的id

 

mod_dl_src:mac

 

Sets the source Ethernet address to mac.

 

mod_dl_dst:mac

 

Sets the destination Ethernet address to mac.

 

mod_nw_src:ip

 

Sets the IPv4 source address to ip.

 

mod_nw_dst:ip

 

Sets the IPv4 destination address to ip.

 

mod_tp_src:port

 

Sets the TCP or UDP source port to port.

 

mod_tp_dst:port

 

Sets the TCP or UDP destination port to port.



4. 删除所有flow
ovs-ofctl del-flows ovs-switch

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值