{"id":38334,"date":"2023-07-28T01:38:13","date_gmt":"2023-07-27T17:38:13","guid":{"rendered":"http:\/\/gulass.cn\/?p=38334"},"modified":"2023-07-28T01:38:13","modified_gmt":"2023-07-27T17:38:13","slug":"docker-openvswitch-vxlan","status":"publish","type":"post","link":"https:\/\/gulass.cn\/docker-openvswitch-vxlan.html","title":{"rendered":"Docker+OpenvSwitch\u8d70\u8fdbVxLAN\u7684\u4e16\u754c"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\ndocker\u662f\u975e\u5e38\u706b\u7684\u5bb9\u5668\u6280\u672f\uff0c\u865a\u62df\u7f51\u7edc\u3001SDN\u7b49\u7f51\u7edc\u4e5f\u5728\u4e0d\u65ad\u7684\u53d1\u5c55\uff0cVxLAN\u662f\u65b0\u578b\u7684\u865a\u62df\u6269\u5c55\u7f51\u7edc\uff0c\u4f5c\u8005\u5728\u6574\u7406\u6587\u6863\u65f6\u5019\u53d1\u73b0\u7f51\u4e0a\u5b9e\u9a8c\uff1a\u4f7f\u7528OpenvSwith \u5728Docker\u4e0a\u642d\u5efaVxLAN\u73af\u5883\uff0c\u62ff\u6765\u5206\u4eab\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u4e00.\u6982\u8ff0<\/strong><\/div>\n

1.\u73af\u5883\uff1a2\u53f0linux\u673a\u5668(host1\u548chost2)\uff0c\u53d1\u884c\u7248\u662fkali2.0\uff0c\u5185\u6838\u7248\u672c\u662f 4.3 \u3002\u6bcf\u53f0\u673a\u5668\u90fd\u5b89\u88c5 Docker \u3001 OpenvSwitch (ovs)\u3002<\/p>\n

2.host1\u548chost2\u5206\u522b\u542f\u52a8 1\u4e2aubuntu \u7684docker\u5bb9\u5668\u3002<\/p>\n

3.\u7f51\u7edc\u7ed3\u6784\uff1a<\/p>\n

3.1\uff1ahost1\u7684 eth0 \uff1a 192.168.2.1 \uff0chost1\u91cc\u9762\u7684docker\u5bb9\u5668ip\u5730\u5740\u662f 10.1.2.3\r\n\r\n3.2\uff1ahost2\u7684 eth0 \uff1a 192.168.2.2 \uff0chost2\u91cc\u9762\u7684docker\u5bb9\u5668ip\u5730\u5740\u662f 10.1.2.4\r\n\r\n3.3\uff1ahost1\u548chost2\u7684eth0\u53ef\u4ee5ping\u901a\u3002<\/pre>\n

4. \u76ee\u6807\u662f\u57282\u4e2a\u4e0d\u540c\u5bbf\u4e3b\u673a\u7684docker\u5bb9\u5668\u4e4b\u95f4\u5efa\u7acbVxLAN\u96a7\u9053\uff0c\u8ba9\u5b83\u4eec\u53ef\u4ee5\u901a\u4fe1 \uff01<\/p>\n

\u4e8c.\u5b89\u88c5\u57fa\u672c\u8f6f\u4ef6<\/strong><\/div>\n

1.\u5b89\u88c5docker\u5e76\u83b7\u53d6ubuntu\u955c\u50cf<\/p>\n

 sudo apt-get install docket.io\r\n sudo docker pull ubuntu<\/pre>\n

2.\u5b89\u88c5openvswitch\u548covs\u7684docker\u8f85\u52a9\u811a\u672c<\/p>\n

 sudo apt-get install openvswitch-switc\r\n \/\/OpenvSwitch \u9879\u76ee\u63d0\u4f9b\u7684\u652f\u6301 Docker \u5bb9\u5668\u7684\u8f85\u52a9\u811a\u672c ovs-docker\r\n wget https:\/\/github.com\/openvswitch\/ovs\/raw\/master\/utilities\/ovs-docker\r\n chmod a+x ovs-docker<\/pre>\n
\u4e09.\u914d\u7f6e<\/strong><\/div>\n

1.\u5728host1\u4e0a\u9762\u7528ovs\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u7f51\u6865\uff0c\u5e76\u7ed9\u7f51\u6865\u4e00\u4e2aip<\/p>\n

 sudo ovs-vsctl add-br vxbr\r\n sudo ifconfig vxbr 10.1.2.1\/24<\/pre>\n

2.\u7ed9\u7f51\u6865\u6dfb\u52a0\u4e00\u4e2avxlan\u7c7b\u578b\u7684\u7aef\u53e3\uff0cremote_ip\u5c31\u662f host2\u7684eth0 \u5730\u5740\uff01\uff01\uff01<\/p>\n

 sudo ovs-vsctl add-port vxbr vxlan -- set interface vxlan type=vxlan options:remote_ip=192.168.2.2<\/pre>\n

3.\u542f\u52a8\u4e00\u4e2a\u6ca1\u6709\u4ee5\u592a\u7f51\u5361\u7684docker\u5bb9\u5668<\/p>\n

 sudo docker run --net=none --privileged=true -it ubuntu<\/pre>\n

\u5e76\u8bb0\u4e0b\u8fd9\u4e2a\u5bb9\u5668\u7684ID\uff0c\u6211\u8fd9\u91cc\u662f\uff1a b062406bc6b6 \u3002\u6b64\u65f6\u5728\u8fd9\u4e2a\u5bb9\u5668\u91cc\u9762ifconfig\u53ea\u80fd\u770b\u5230\u4e00\u4e2alo\u7684\u8bbe\u5907\u3002<\/p>\n

4.\u7ed9\u5bb9\u5668\u673a\u6307\u5b9a\u4e00\u4e2aeth0\u5e76\u7ed1\u5b9a\u5230\u5bbf\u4e3b\u673a\u7684vxbr\u7f51\u6865<\/p>\n

 sudo .\/ovs-docker add-port vxbr eth0 b062406bc6b6<\/pre>\n

\u6b64\u65f6\u56de\u5230\u5bb9\u5668\u91cc\u9762\uff0cifconfig\u4f1a\u770b\u5230\u51fa\u73b0\u4e86\u4e00\u4e2aeht0\u3002\u7ed9\u5b83\u4e00\u4e2aip\uff1a<\/p>\n

 ifconfig eth0 10.1.2.3\/24<\/pre>\n

5.\u67e5\u770bovs\u914d\u7f6e<\/p>\n

 sudo ovs-vsctl show<\/pre>\n

\"1\"
\n\u6211\u4eec\u53ef\u4ee5\u770b\u5230vxbr\u7f51\u6865\u4e0a\u9762\u6709 3\u4e2a\u7aef\u53e3 \uff0c\u4e00\u4e2a\u662f \u81ea\u5df1\u8ddf\u672c\u673a\u901a\u4fe1 (\u8fd9\u91cc\u662f\u672c\u673a\u7684eth0)\u7684\u7aef\u53e3\uff0c\u4e00\u4e2a\u662fvxlan\u7684\u7aef\u53e3\uff0c\u6700\u540e\u4e00\u4e2a\u662f docker \u5bb9\u5668\u673a\u7684eth0\u3002<\/p>\n

host2\u914d\u7f6e\u8ddf\u4e0a\u9762\u5dee\u4e0d\u591a\uff0c\u628ahost2\u7684\u865a\u62df\u7f51\u6865vxbr\u6539\u4e3a10.1.2.2\/24\uff0cvxlan\u7684remote_ip\u6539\u6210host1\u7684192.168.2.1\uff0chost2\u7684docker\u5bb9\u5668\u673aip\u6539\u4e3a10.1.2.4\/24<\/p>\n

\u56db.\u9a8c\u8bc1<\/strong><\/div>\n

\u6b64\u65f6\u7684\u7f51\u7edc\u7ed3\u6784\uff1a<\/p>\n

host1\u7684eth0\uff1a192.168.2. 1 \uff0cvxbr\uff1a10.1.2. 1 \uff0cdocker\u5bb9\u5668\u673a\u7684eth0\uff1a10.1.2. 3 \u3002docker\u5bb9\u5668\u7684eth0\u5728host1\u7684vxbr\u4e0a\u9762\u3002<\/p>\n

host2\u7684eth0\uff1a192.168.2. 2 \uff0cvxbr\uff1a10.1.2. 2 \uff0cdocker\u5bb9\u5668\u673a\u7684eth0\uff1a10.1.2. 4 \u3002docker\u5bb9\u5668\u7684eth0\u5728host2\u7684vxbr\u4e0a\u9762\u3002<\/p>\n

\u5728host1\u7684docker\u5bb9\u5668\u673a\u91cc\u9762ping host2\u7684docker\u5bb9\u5668\u673a\uff0c wireshark\u6293\u5305 \uff1a<\/p>\n

\"2\"<\/p>\n

\u53ef\u4ee5\u770b\u5230\u5bb9\u5668\u673a\u4e4b\u95f4\u7684\u901a\u4fe1 \u88ab\u5c01\u88c5\u5728\u4e00\u4e2aUDP\u62a5\u6587\u91cc\u9762 \uff0c\u8fd9\u4e2aUDP\u7684\u901a\u4fe1\u662f\u901a\u8fc7host1\u548chost2\u7684 eth0\u8f6c\u53d1 \u3002<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.cnblogs.com\/yuuyuu\/p\/5180827.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/gulass.cn\/docker-openvswitch-vxlan.html<\/a>\u7f16\u8f91\uff1a\u9676\u6b66\u6770\uff0c\u5ba1\u6838\u5458\uff1a\u51af\u742a<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb docker\u662f\u975e\u5e38\u706b\u7684\u5bb9\u5668\u6280\u672f\uff0c\u865a\u62df\u7f51\u7edc\u3001SDN\u7b49\u7f51\u7edc\u4e5f\u5728\u4e0d\u65ad\u7684\u53d1\u5c55\uff0cVxLAN\u662f\u65b0\u578b\u7684\u865a\u62df\u6269\u5c55\u7f51\u7edc\uff0c\u4f5c […]<\/p>\n","protected":false},"author":63,"featured_media":38342,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-38334","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/38334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=38334"}],"version-history":[{"count":13,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/38334\/revisions"}],"predecessor-version":[{"id":278957,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/38334\/revisions\/278957"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/38342"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=38334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=38334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=38334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}