1. 程式人生 > >利用ODL建立VxLAN網路

利用ODL建立VxLAN網路

說明:mininet1(192.168.1.209),mininet2(192.168.1.211),odl(192.168.1.217)為三臺虛機,在同一網段,其中odl虛機安裝了opendaylight-boron-sr3,mininet1和mininet2都安裝了mininet

1.讓mininet1和mininet2連結上odl,並設定manager

mininet1和mininet2進行操作(這裡是設定監聽管理埠):

sh ovs-vsctl set-manager ptcp:6640

說明:下面的remote-ip為需要設定manager的mininet的ip
ODL主機發送以下Rest請求到mininet1:
url:http://192.168.1.217:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2FHOST1


Method:PUT
Bady:

{
    "node": [
        {
            "node-id": "ovsdb://HOST1",
            "ovsdb:connection-info": {
                "remote-ip": "192.168.1.209",
                "remote-port": "6640"
            }
        }
    ]
}

ODL主機發送以下Rest請求到mininet2:
url:http://192.168.1.217:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2FHOST2


Method:PUT
Bady:

{
    "node": [
        {
            "node-id": "ovsdb://HOST2",
            "ovsdb:connection-info": {
                "remote-ip": "192.168.1.211",
                "remote-port": "6640"
            }
        }
    ]
}

2.建立網橋
在HOST1上建立網橋:
url:http://192.168.1.217:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2FHOST1%2Fbridge%2Fbrtest


Method:PUT
Body:

{
    "node": [
        {
            "node-id": "ovsdb://HOST1/bridge/brtest",
            "ovsdb:bridge-name": "brtest",
            "ovsdb:protocol-entry": [
                {
                    "protocol": "ovsdb:ovsdb-bridge-protocol-openflow-13"
                }
            ],
            "ovsdb:managed-by": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://HOST1']",
            "hwvtep:managed-by": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://HOST1']"
        }
    ]
}

在HOST2上建立網橋:
url:http://192.168.1.217:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2FHOST2%2Fbridge%2Fbrtest
Method:PUT
Body:

{
    "node": [
        {
            "node-id": "ovsdb://HOST2/bridge/brtest",
            "ovsdb:bridge-name": "brtest",
            "ovsdb:protocol-entry": [
                {
                    "protocol": "ovsdb:ovsdb-bridge-protocol-openflow-13"
                }
            ],
            "ovsdb:managed-by": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://HOST2']",
            "hwvtep:managed-by": "/network-topology:network-topology/network-topology:topology[network-topology:topology-id='ovsdb:1']/network-topology:node[network-topology:node-id='ovsdb://HOST2']"
        }
    ]
}

3.建立埠
說明:mininet1中body裡面value的值為mininet2的ip
在mininet1上建立vxlan port:
url:http://192.168.1.217:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2FHOST1%2Fbridge%2Fbrtest/termination-point/testport
Methos:put
Body:

{
    "termination-point": [
        {
            "tp-id": "testport",
            "ovsdb:name": "testport",
            "ovsdb:interface-type": "ovsdb:interface-type-vxlan",
            "ovsdb:options": [
                {
                    "option": "remote_ip",
                    "value": "192.168.1.211"
                }
            ]
        }
    ]
}

在mininet2上建立vxlan port:
url:http://192.168.1.217:8181/restconf/config/network-topology:network-topology/topology/ovsdb:1/node/ovsdb:%2F%2FHOST2%2Fbridge%2Fbrtest/termination-point/testport
Methos:put
Body:

{
    "termination-point": [
        {
            "tp-id": "testport",
            "ovsdb:name": "testport",
            "ovsdb:interface-type": "ovsdb:interface-type-vxlan",
            "ovsdb:options": [
                {
                    "option": "remote_ip",
                    "value": "192.168.1.209"
                }
            ]
        }
    ]
}

4.給mininet1和mininet2中的網橋設定ip(命令列執行:ifconfig brtest 30.0.0.3/8 upifconfig brtest 30.0.0.2/8 up
(ip為同子網不需要設定路由,非同子網自行設定路由)
5.驗證:
在mininet1上用ping測試:ping 30.0.0.2

注意:要麼同時odl發指令,要麼同時手動配,否則建立的vxlan是無法通訊的