安装如下插件:
1 |
feature:install odl-vtn-manager-neutron |
查看端口,确保如下端口开放:
1 2 3 4 |
netstat -tnupl Ports 6633/6653 for OpenFlow. Port 6640 for OVS (Openflow Manager). Port 8910 for Neutron requests. |
停止openvswitch agent服务清除ovs桥:
1 2 3 4 5 6 7 8 |
sudo systemctl stop neutron-openvswitch-agent sudo systemctl disable neutron-openvswitch-agent sudo systemctl stop openvswitch sudo rm -rf /var/log/openvswitch/* sudo rm -rf /etc/openvswitch/conf.db sudo systemctl start openvswitch sudo ovs-vsctl show |
停止neutron server服务:
1 |
systemctl stop neutron-server |
修改neutron的配置:
1 2 3 4 5 6 7 8 9 10 |
sudo crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers opendaylight sudo crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan sudo crudini --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers vxlan sudo crudini --set /etc/neutron/dhcp_agent.ini DEFAULT ovs_use_veth True vi /etc/neutron/plugins/ml2/ml2_conf.ini [ml2_odl] password = admin username = admin url = http://172.31.2.70:8080/controller/nb/v2/neutron |
重启服务:
1 2 |
systemctl restart neutron-server systemctl restart neutron-dhcp-agent |
设置ovs的sdn管理ip:
1 |
ovs-vsctl set-manager tcp:172.31.2.70:6640 |
查看桥:
1 2 3 4 5 6 7 8 9 10 11 |
[root@sdn-openstack-l ~]# ovs-vsctl show a7eb0c6f-9f27-4ae2-bedc-f5d08e75e567 Manager "tcp:172.31.2.70:6640" is_connected: true Bridge br-int Controller "tcp:172.31.2.70:6633" is_connected: true fail_mode: secure Port "ens33" Interface "ens33" error: "could not open network device ens33 (No such device)" |
其中ens33这个接口是用来和其他计算节点通信使用的,如果在odl的配置中未做配置,则默认使用ens33,添加vtn.ini配置:
1 2 3 4 5 |
vi distribution-karaf-0.3.3-Lithium-SR3/configuration/vtn.ini bridgename=br-int portname=eth1 protocols=OpenFlow13 failmode=secure |
eth1用来做虚拟机的数据网口。
添加缺失流表项(如果没有可匹配的流表,则匹配该流表,该流表的作用是去控制器上取策略):
1 |
ovs-ofctl --protocols=OpenFlow13 add-flow br-int priority=0,actions=output:CONTROLLER |
通过openstack创建网络及虚拟机:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@sdn-openstack-l ~(keystone_admin)]# neutron net-list +--------------------------------------+------+-----------------------------------------------------+ | id | name | subnets | +--------------------------------------+------+-----------------------------------------------------+ | eb83537d-74d4-4691-bdea-fe550c04f93f | int | df3e0e68-e565-4618-a749-90a6a6a533cb 111.22.33.0/24 | | aa5ac973-90ed-4c79-a99b-e2976fe7c948 | ext | f557793a-5c37-4272-b573-2291b988ef1f 172.31.0.0/20 | +--------------------------------------+------+-----------------------------------------------------+ [root@sdn-openstack-l ~(keystone_admin)]# nova list +--------------------------------------+------+--------+------------+-------------+-----------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+------+--------+------------+-------------+-----------------+ | 9cb7ec97-9c03-46a9-a937-4622aa53bb10 | 1 | ACTIVE | - | Running | int=111.22.33.3 | | bbd79667-a75d-4832-92ea-3db97c41525a | 2 | ACTIVE | - | Running | int=111.22.33.4 | +--------------------------------------+------+--------+------------+-------------+-----------------+ |
登录虚拟机查看是否获取ip:
两台虚拟机互ping:
此时查看br-int的流表项:
1 2 3 4 5 |
[root@sdn-openstack-l ~(keystone_admin)]# ovs-ofctl --protocols=OpenFlow13 dump-flows br-int OFPST_FLOW reply (OF1.3) (xid=0x2): cookie=0x7f56000000000007, duration=3.638s, table=0, n_packets=0, n_bytes=0, idle_timeout=300, send_flow_rem priority=10,in_port=3,vlan_tci=0x0000/0x1fff,dl_src=fa:16:3e:63:3f:87,dl_dst=fa:16:3e:5d:a0:26 actions=output:4 cookie=0x7f56000000000008, duration=3.635s, table=0, n_packets=0, n_bytes=0, idle_timeout=300, send_flow_rem priority=10,in_port=4,vlan_tci=0x0000/0x1fff,dl_src=fa:16:3e:5d:a0:26,dl_dst=fa:16:3e:63:3f:87 actions=output:3 cookie=0x0, duration=2083.942s, table=0, n_packets=305, n_bytes=17132, priority=0 actions=CONTROLLER:65535 |
注意:此流表项是有时效的,过时会失效,再次通信的时候会去odl控制器获取。
查看ovs交换机:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@sdn-openstack-l ~(keystone_admin)]# ovs-vsctl show a7eb0c6f-9f27-4ae2-bedc-f5d08e75e567 Manager "tcp:172.31.2.70:6640" is_connected: true Bridge br-int Controller "tcp:172.31.2.70:6633" is_connected: true fail_mode: secure Port "tap941c0870-d1" Interface "tap941c0870-d1" Port "tap14c941fa-16" Interface "tap14c941fa-16" Port "tap2df81842-69" Interface "tap2df81842-69" Port "ens33" Interface "ens33" error: "could not open network device ens33 (No such device)" Port "tapf3885787-54" Interface "tapf3885787-54" |
可通过api接口获取网络信息:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
[root@opendaylight ~]# curl -u admin:admin http://172.31.2.70:8080/controller/nb/v2/neutron/networks { "networks" : [ { "id" : "aa5ac973-90ed-4c79-a99b-e2976fe7c948", "name" : "ext", "admin_state_up" : true, "shared" : false, "tenant_id" : "b528a90933ce44548629ed4c2e433799", "router:external" : true, "provider:network_type" : "vxlan", "provider:segmentation_id" : "111", "status" : "ACTIVE", "subnets" : [ "f557793a-5c37-4272-b573-2291b988ef1f" ] }] [root@opendaylight ~]# curl -u admin:admin http://172.31.2.70:8080/controller/nb/v2/neutron/subnets { "subnets" : [ { "id" : "df3e0e68-e565-4618-a749-90a6a6a533cb", "network_id" : "eb83537d-74d4-4691-bdea-fe550c04f93f", "name" : "int", "ip_version" : 4, "cidr" : "111.22.33.0/24", "gateway_ip" : "111.22.33.1", "dns_nameservers" : [ ], "allocation_pools" : [ { "start" : "111.22.33.2", "end" : "111.22.33.254" } ], "host_routes" : [ ], "enable_dhcp" : true, "tenant_id" : "b528a90933ce44548629ed4c2e433799", "ipv6_address_mode" : null, "ipv6_ra_mode" : null }] [root@opendaylight ~]# curl -u admin:admin http://172.31.2.70:8080/controller/nb/v2/neutron/ports { "ports" : [{ "id" : "14c941fa-161a-4f9b-a9fa-5ee33ecfb76b", "network_id" : "eb83537d-74d4-4691-bdea-fe550c04f93f", "name" : "", "admin_state_up" : true, "mac_address" : "FA:16:3E:5D:A0:26", "fixed_ips" : [ { "ip_address" : "111.22.33.4", "subnet_id" : "df3e0e68-e565-4618-a749-90a6a6a533cb" } ], "device_id" : "bbd79667-a75d-4832-92ea-3db97c41525a", "device_owner" : "compute:nova", "tenant_id" : "b528a90933ce44548629ed4c2e433799", "security_groups" : [ { "id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "name" : "default", "description" : "Default security group", "tenant_id" : "b528a90933ce44548629ed4c2e433799", "security_group_rules" : [ { "id" : "1b5ff8c5-3e2c-43a8-9351-6938848dd4f2", "direction" : "ingress", "protocol" : "tcp", "port_range_min" : 12233, "port_range_max" : 12233, "ethertype" : "IPv4", "remote_ip_prefix" : "0.0.0.0/0", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" }, { "id" : "1c89f8db-54d4-491d-93c7-f00d69584c41", "direction" : "ingress", "protocol" : "tcp", "port_range_min" : 111, "port_range_max" : 111, "ethertype" : "IPv4", "remote_ip_prefix" : "0.0.0.0/0", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" }, { "id" : "31c227b6-46ff-4d1b-ace6-a6782e8f7229", "direction" : "egress", "ethertype" : "IPv4", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" }, { "id" : "490fbbb3-db80-498e-9de8-7c4b71ae71bb", "direction" : "ingress", "ethertype" : "IPv4", "remote_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" }, { "id" : "569f66b9-54a2-48d3-9078-aab993645ffa", "direction" : "ingress", "ethertype" : "IPv6", "remote_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" }, { "id" : "a5c2ca5c-40a7-4fed-8f97-513ea7c2fd8c", "direction" : "ingress", "protocol" : "tcp", "port_range_min" : 12233, "port_range_max" : 12233, "ethertype" : "IPv4", "remote_ip_prefix" : "172.31.2.0/24", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" }, { "id" : "d581fb3b-bdca-4528-bf0f-910b2dfe3a50", "direction" : "egress", "ethertype" : "IPv6", "security_group_id" : "08541843-6d9a-46e6-a422-61c09f7b6fc1", "tenant_id" : "b528a90933ce44548629ed4c2e433799" } ] } ], "allowed_address_pairs" : [ ], "binding:host_id" : "sdn-openstack-l", "binding:vnic_type" : "normal", "binding:vif_type" : "ovs", "binding:vif_details" : [ { "port_filter" : true } ], "extra_dhcp_opts" : [ ] }] |
遇到的问题:
目前只有二层是可通信的,即创建路由后,无法到达网关。