{"id":241582,"date":"2022-05-08T09:59:22","date_gmt":"2022-05-08T01:59:22","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=241582"},"modified":"2022-04-29T10:00:30","modified_gmt":"2022-04-29T02:00:30","slug":"linux-opensource-sdn","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-opensource-sdn.html","title":{"rendered":"\u628aLinux\u53d8\u6210\u5f00\u6e90SDN"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u4f7f\u7528\u5f00\u6e90\u8def\u7531\u534f\u8bae\u6808 Quagga\uff0c\u4f7f\u4f60\u7684 Linux \u7cfb\u7edf\u6210\u4e3a\u4e00\u53f0\u8def\u7531\u5668\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u7f51\u7edc\u8def\u7531\u534f\u8bae\u5206\u4e3a\u4e24\u5927\u7c7b\uff1a\u5185\u90e8\u7f51\u5173\u534f\u8bae\u548c\u5916\u90e8\u7f51\u5173\u534f\u8bae\u3002\u8def\u7531\u5668\u4f7f\u7528\u5185\u90e8\u7f51\u5173\u534f\u8bae\u5728\u5355\u4e2a\u81ea\u6cbb\u7cfb\u7edf\u5185\u5171\u4eab\u4fe1\u606f\u3002\u5982\u679c\u4f60\u7528\u7684\u662f Linux\uff0c\u5219\u53ef\u4ee5\u901a\u8fc7\u5f00\u6e90\uff08GPLv2\uff09\u8def\u7531\u534f\u8bae\u6808 Quagga \u4f7f\u5176\u8868\u73b0\u5f97\u50cf\u4e00\u53f0\u8def\u7531\u5668\u3002<\/p>\n

Quagga \u662f\u4ec0\u4e48\uff1f<\/strong><\/div>\n

Quagga \u662f\u4e00\u4e2a\u8def\u7531\u8f6f\u4ef6\u5305\uff0c\u5e76\u4e14\u662f GNU Zebra \u7684\u4e00\u4e2a\u5206\u652f\u3002\u5b83\u4e3a\u7c7b Unix \u5e73\u53f0\u63d0\u4f9b\u4e86\u6240\u6709\u4e3b\u6d41\u8def\u7531\u534f\u8bae\u7684\u5b9e\u73b0\uff0c\u4f8b\u5982\u5f00\u653e\u6700\u77ed\u8def\u5f84\u4f18\u5148\uff08OSPF\uff09\uff0c\u8def\u7531\u4fe1\u606f\u534f\u8bae\uff08RIP\uff09\uff0c\u8fb9\u754c\u7f51\u5173\u534f\u8bae\uff08BGP\uff09\u548c\u4e2d\u95f4\u7cfb\u7edf\u5230\u4e2d\u95f4\u7cfb\u7edf\u534f\u8bae\uff08IS-IS\uff09\u3002<\/p>\n

\u5c3d\u7ba1 Quagga \u5b9e\u73b0\u4e86 IPv4 \u548c IPv6 \u7684\u8def\u7531\u534f\u8bae\uff0c\u4f46\u5b83\u5e76\u4e0d\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u8def\u7531\u5668\u3002\u4e00\u4e2a\u771f\u6b63\u7684\u8def\u7531\u5668\u4e0d\u4ec5\u5b9e\u73b0\u4e86\u6240\u6709\u8def\u7531\u534f\u8bae\uff0c\u800c\u4e14\u8fd8\u6709\u8f6c\u53d1\u7f51\u7edc\u6d41\u91cf\u7684\u80fd\u529b\u3002 Quagga \u4ec5\u4ec5\u5b9e\u73b0\u4e86\u8def\u7531\u534f\u8bae\u6808\uff0c\u800c\u8f6c\u53d1\u7f51\u7edc\u6d41\u91cf\u7684\u5de5\u4f5c\u7531 Linux \u5185\u6838\u5904\u7406\u3002<\/p>\n

\u67b6\u6784<\/strong><\/div>\n

Quagga \u901a\u8fc7\u7279\u5b9a\u534f\u8bae\u7684\u5b88\u62a4\u7a0b\u5e8f\u5b9e\u73b0\u4e0d\u540c\u7684\u8def\u7531\u534f\u8bae\u3002\u5b88\u62a4\u7a0b\u5e8f\u540d\u79f0\u4e0e\u8def\u7531\u534f\u8bae\u76f8\u540c\uff0c\u52a0\u4e86\u5b57\u6bcd\u201cd\u201d\u4f5c\u4e3a\u540e\u7f00\u3002Zebra \u662f\u6838\u5fc3\uff0c\u4e5f\u662f\u4e0e\u534f\u8bae\u65e0\u5173\u7684\u5b88\u62a4\u8fdb\u7a0b\uff0c\u5b83\u4e3a\u5185\u6838\u63d0\u4f9b\u4e86\u4e00\u4e2a\u62bd\u8c61\u5c42\uff0c\u5e76\u901a\u8fc7 TCP \u5957\u63a5\u5b57\u5411 Quagga \u5ba2\u6237\u7aef\u63d0\u4f9b Zserv API\u3002\u6bcf\u4e2a\u7279\u5b9a\u534f\u8bae\u7684\u5b88\u62a4\u7a0b\u5e8f\u8d1f\u8d23\u8fd0\u884c\u76f8\u5173\u7684\u534f\u8bae\uff0c\u5e76\u57fa\u4e8e\u4ea4\u6362\u7684\u4fe1\u606f\u6765\u5efa\u7acb\u8def\u7531\u8868\u3002<\/p>\n

\"\"<\/p>\n

\u73af\u5883<\/strong><\/div>\n

\u672c\u6559\u7a0b\u901a\u8fc7 Quagga \u5b9e\u73b0\u7684 OSPF \u534f\u8bae\u6765\u914d\u7f6e\u52a8\u6001\u8def\u7531\u3002\u8be5\u73af\u5883\u5305\u62ec\u4e24\u4e2a\u540d\u4e3a Alpha \u548c Beta \u7684 CentOS 7.7 \u4e3b\u673a\u3002\u4e24\u53f0\u4e3b\u673a\u5171\u4eab\u8bbf\u95ee 192.168.122.0\/24 \u7f51\u7edc\u3002<\/p>\n

\u4e3b\u673a Alpha\uff1a<\/strong><\/span><\/div>\n

IP\uff1a192.168.122.100\/24 \u7f51\u5173\uff1a192.168.122.1<\/p>\n

\u4e3b\u673a Beta\uff1a<\/strong><\/span><\/div>\n

IP\uff1a192.168.122.50\/24 \u7f51\u5173\uff1a192.168.122.1<\/p>\n

\u5b89\u88c5\u8f6f\u4ef6\u5305<\/strong><\/div>\n

\u9996\u5148\uff0c\u5728\u4e24\u53f0\u4e3b\u673a\u4e0a\u5b89\u88c5 Quagga \u8f6f\u4ef6\u5305\u3002\u5b83\u5b58\u5728\u4e8e CentOS \u57fa\u7840\u4ed3\u5e93\u4e2d\uff1a<\/p>\n

\r\nyum install quagga -y\r\n<\/pre>\n
\u542f\u7528 IP \u8f6c\u53d1<\/strong><\/div>\n

\u63a5\u4e0b\u6765\uff0c\u5728\u4e24\u53f0\u4e3b\u673a\u4e0a\u542f\u7528 IP \u8f6c\u53d1\uff0c\u56e0\u4e3a\u5b83\u5c06\u7531 Linux \u5185\u6838\u6765\u6267\u884c\uff1a<\/p>\n

\r\nsysctl -w net.ipv4.ip_forward = 1\r\nsysctl -p\r\n<\/pre>\n
\u914d\u7f6e<\/strong><\/div>\n

\u73b0\u5728\uff0c\u8fdb\u5165 \/etc\/quagga \u76ee\u5f55\u5e76\u4e3a\u4f60\u7684\u8bbe\u7f6e\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u3002\u4f60\u9700\u8981\u4e09\u4e2a\u6587\u4ef6\uff1a<\/p>\n

  • zebra.conf\uff1aQuagga \u5b88\u62a4\u7a0b\u5e8f\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u5b9a\u4e49\u63a5\u53e3\u53ca\u5176 IP \u5730\u5740\u548c IP \u8f6c\u53d1<\/li>\n
  • ospfd.conf\uff1a\u534f\u8bae\u914d\u7f6e\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728\u5176\u4e2d\u5b9a\u4e49\u5c06\u901a\u8fc7 OSPF \u534f\u8bae\u63d0\u4f9b\u7684\u7f51\u7edc<\/li>\n
  • daemons\uff1a\u4f60\u5c06\u5728\u5176\u4e2d\u6307\u5b9a\u9700\u8981\u8fd0\u884c\u7684\u76f8\u5173\u7684\u534f\u8bae\u5b88\u62a4\u7a0b\u5e8f<\/li>\n

    \u5728\u4e3b\u673a Alpha \u4e0a\uff0c<\/p>\n

    \r\n[root@alpha]# cat \/etc\/quagga\/zebra.conf\r\ninterface eth0\r\n ip address 192.168.122.100\/24\r\n ipv6 nd suppress-ra\r\ninterface eth1\r\n ip address 10.12.13.1\/24\r\n ipv6 nd suppress-ra\r\ninterface lo\r\nip forwarding\r\nline vty\r\n[root@alpha]# cat \/etc\/quagga\/ospfd.conf\r\ninterface eth0\r\ninterface eth1\r\ninterface lo\r\nrouter ospf\r\n network 192.168.122.0\/24 area 0.0.0.0\r\n network 10.12.13.0\/24 area 0.0.0.0\r\nline vty\r\n[root@alphaa ~]# cat \/etc\/quagga\/daemons\r\nzebra=yes\r\nospfd=yes\r\n\r\n<\/pre>\n

    \u5728\u4e3b\u673a Beta \u4e0a\uff0c<\/p>\n

    \r\n[root@beta quagga]# cat zebra.conf\r\ninterface eth0\r\n ip address 192.168.122.50\/24\r\n ipv6 nd suppress-ra\r\ninterface eth1\r\n ip address 10.10.10.1\/24\r\n ipv6 nd suppress-ra\r\ninterface lo\r\nip forwarding\r\nline vty\r\n[root@beta quagga]# cat ospfd.conf\r\ninterface eth0\r\ninterface eth1\r\ninterface lo\r\nrouter ospf\r\n network 192.168.122.0\/24 area 0.0.0.0\r\n network 10.10.10.0\/24 area 0.0.0.0\r\nline vty\r\n[root@beta ~]# cat \/etc\/quagga\/daemons\r\nzebra=yes\r\nospfd=yes<\/pre>\n
    \u914d\u7f6e\u9632\u706b\u5899<\/strong><\/div>\n

    \u8981\u4f7f\u7528 OSPF \u534f\u8bae\uff0c\u5fc5\u987b\u5141\u8bb8\u5b83\u901a\u8fc7\u9632\u706b\u5899\uff1a<\/p>\n

    \r\nfirewall-cmd --add-protocol=ospf \u2013permanent\r\nfirewall-cmd \u2013reload<\/pre>\n

    \u73b0\u5728\uff0c\u542f\u52a8 zebra \u548c ospfd \u5b88\u62a4\u7a0b\u5e8f\u3002<\/p>\n

    \r\n# systemctl start zebra\r\n# systemctl start ospfd<\/pre>\n

    \u7528\u4e0b\u9762\u547d\u4ee4\u5728\u4e24\u4e2a\u4e3b\u673a\u4e0a\u67e5\u770b\u8def\u7531\u8868:<\/p>\n

    \r\n[root@alpha ~]# ip route show  \r\ndefault via 192.168.122.1 dev eth0 proto static metric 100\r\n10.10.10.0\/24 via 192.168.122.50 dev eth0 proto zebra metric 20\r\n10.12.13.0\/24 dev eth1 proto kernel scope link src 10.12.13.1\r\n192.168.122.0\/24 dev eth0 proto kernel scope link src 192.168.122.100 metric 100<\/pre>\n

    \u4f60\u53ef\u4ee5\u770b\u5230 Alpha \u4e0a\u7684\u8def\u7531\u8868\u5305\u542b\u901a\u8fc7 192.168.122.50 \u5230\u8fbe 10.10.10.0\/24 \u7684\u8def\u7531\u9879\uff0c\u5b83\u662f\u901a\u8fc7\u534f\u8bae zebra \u83b7\u53d6\u7684\u3002\u540c\u6837\uff0c\u5728\u4e3b\u673a Beta \u4e0a\uff0c\u8be5\u8868\u5305\u542b\u901a\u8fc7 192.168.122.100 \u5230\u8fbe\u7f51\u7edc 10.12.13.0\/24 \u7684\u8def\u7531\u9879\u3002<\/p>\n

    \r\n[root@beta ~]# ip route show\r\ndefault via 192.168.122.1 dev eth0 proto static metric 100\r\n10.10.10.0\/24 dev eth1 proto kernel scope link src 10.10.10.1\r\n10.12.13.0\/24 via 192.168.122.100 dev eth0 proto zebra metric 20\r\n192.168.122.0\/24 dev eth0 proto kernel scope link src 192.168.122.50 metric 100<\/pre>\n
    \u7ed3\u8bba<\/strong><\/div>\n

    \u5982\u4f60\u6240\u89c1\uff0c\u73af\u5883\u548c\u914d\u7f6e\u76f8\u5bf9\u7b80\u5355\u3002\u8981\u589e\u52a0\u590d\u6742\u6027\uff0c\u4f60\u53ef\u4ee5\u5411\u8def\u7531\u5668\u6dfb\u52a0\u66f4\u591a\u7f51\u7edc\u63a5\u53e3\uff0c\u4ee5\u4e3a\u66f4\u591a\u7f51\u7edc\u63d0\u4f9b\u8def\u7531\u3002\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u6cd5\u6765\u5b9e\u73b0 BGP \u548c RIP \u534f\u8bae\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

    \u7f51\u7edc\u8def\u7531\u534f\u8bae\u5206\u4e3a\u4e24\u5927\u7c7b\uff1a\u5185\u90e8\u7f51\u5173\u534f\u8bae\u548c\u5916\u90e8\u7f51\u5173\u534f\u8bae\u3002\u8def\u7531\u5668\u4f7f\u7528\u5185\u90e8\u7f51\u5173\u534f\u8bae\u5728\u5355\u4e2a\u81ea\u6cbb\u7cfb\u7edf\u5185\u5171\u4eab\u4fe1\u606f\u3002\u5982\u679c\u4f60\u7528\u7684 […]<\/p>\n","protected":false},"author":317,"featured_media":235349,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-241582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/317"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=241582"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241582\/revisions"}],"predecessor-version":[{"id":241585,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/241582\/revisions\/241585"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/235349"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=241582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=241582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=241582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}