{"id":1824,"date":"2025-06-02T17:32:27","date_gmt":"2025-06-02T09:32:27","guid":{"rendered":"http:\/\/113.45.254.23\/?p=1824"},"modified":"2025-06-02T17:34:09","modified_gmt":"2025-06-02T09:34:09","slug":"%e4%b8%89%e5%b1%82%e4%ba%a4%e6%8d%a2%e6%9c%ba%e5%92%8c%e8%b7%af%e7%94%b1%e5%99%a8%e7%9a%84ospf","status":"publish","type":"post","link":"http:\/\/113.45.254.23\/?p=1824","title":{"rendered":"\u4e09\u5c42\u4ea4\u6362\u673a\u548c\u8def\u7531\u5668\u7684OSPF"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u4e00\u3001\u5b9e\u9a8c\u62d3\u6251\u56fe<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/113.45.254.23\/wp-content\/uploads\/2025\/06\/image-5.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" width=\"696\" height=\"308\" data-original=\"http:\/\/113.45.254.23\/wp-content\/uploads\/2025\/06\/image-5.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" class=\"wp-image-1825\"  sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e8c\u3001\u914d\u7f6e3SW1\u30013SW2 \u5212\u5206vlan\u3001\u914d\u7f6e\u865a\u63a5\u53e3IP\u3001\u5212\u5206\u63a5\u53e3vlan<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Huawei>system-view \u8fdb\u5165\u89c6\u56fe\u6a21\u5f0f\nEnter system view, return user view with Ctrl+Z.\n&#91;Huawei]undo info-center enable \u5173\u95ed\u6d88\u606f\u63a7\u5236\u53f0\nInfo: Information center is disabled.\n&#91;Huawei]sysname sw1 \u4fee\u6539\u540d\u79f0\u4e3a\uff1asw1\n&#91;3sw1]vlan batch 10 20 \u521b\u5efavlan10\u548c20 \u521b\u5efavlan10\u548c20\nInfo: This operation may take a few seconds. Please wait for a moment...done.\n&#91;3sw1]interface vlanif 10 \u8fdb\u5165vlan10\u7684\u865a\u63a5\u53e3\n&#91;3sw1-Vlanif10]ip address 192.168.10.1 24  IP\u5730\u5740192.168.10.1\uff0c\u5b50\u7f51\u63a9\u780124\n&#91;3sw1-Vlanif10]quit \u9000\u51fa\n&#91;3sw1-Vlanif10]interface g0\/0\/1 \u8fdb\u5165g0\/0\/1\u63a5\u53e3 \u8fdb\u5165g0\/0\/1\u63a5\u53e3  \u8fdb\u5165g0\/0\/1\u63a5\u53e3\n&#91;3sw1-GigabitEthernet0\/0\/1]port link-type access \u7aef\u53e3\u94fe\u8def\u7c7b\u578b\u4e3a\u63a5\u5165\u94fe\u8def\t\u7aef\u53e3\u94fe\u8def\u7c7b\u578b\u4e3a\u4ecb\u5165\u94fe\u8def\n&#91;3sw1-GigabitEthernet0\/0\/1]port default vlan 10 \u7aef\u53e3\u63a5\u5165vlan10 \u7aef\u53e3\u63a5\u5165vlan10\n&#91;3sw1-GigabitEthernet0\/0\/1]quit \u9000\u51fa<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Huawei>system-view \u8fdb\u5165\u89c6\u56fe\u6a21\u5f0f \nEnter system view, return user view with Ctrl+Z.\n&#91;Huawei]undo info-center enable \u5173\u95ed\u6d88\u606f\u63a7\u5236\u53f0\nInfo: Information center is disabled.\n&#91;Huawei]sysname sw2 \u4fee\u6539\u540d\u79f0\u4e3a\uff1asw2\n&#91;3sw2]vlan batch 10 20 \u521b\u5efavlan10\u548c20\nInfo: This operation may take a few seconds. Please wait for a moment...done.\n&#91;3sw2]interface vlanif 20 \u8fdb\u5165vlan20\u7684\u865a\u63a5\u53e3\n&#91;3sw2-Vlanif20]ip address 192.168.20.1 24 ip\u5730\u5740192.168.20.1 \u5b50\u7f51\u63a9\u780124\n&#91;3sw2-Vlanif20]quit \u9000\u51fa\n&#91;3sw2]interface g0\/0\/1 \u8fdb\u5165g0\/0\/1\u63a5\u53e3 \u8fdb\u5165g0\/0\/1\u63a5\u53e3\n&#91;3sw2-GigabitEthernet0\/0\/1]port link-type access \u7aef\u53e3\u94fe\u8def\u7c7b\u578b\u4e3a\u63a5\u5165\u94fe\u8def \u7aef\u53e3\u94fe\u8def\u7c7b\u578b\u4e3a\u63a5\u5165\u94fe\u8def\n&#91;3sw2-GigabitEthernet0\/0\/1]port default vlan 20 \u7aef\u53e3\u63a5\u5165vlan20\n&#91;3sw2-GigabitEthernet0\/0\/1]quit \u9000\u51fa<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e09\u3001\u8bbe\u7f6eR1\u8def\u7531\u5668\u63a5\u53e3IP<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Huawei&gt;system-view \u8fdb\u5165\u89c6\u56fe\u6a21\u5f0f\nEnter system view, return user view with Ctrl+Z.\n&#91;Huawei]undo info-center enable \u5173\u95ed\u6d88\u606f\u63a7\u5236\u53f0\nInfo: Information center is disabled.\n&#91;Huawei]sysname r1 \u66f4\u6539\u540d\u79f0\u4e3a\uff1ar1\n&#91;r1]interface g0\/0\/0 \u8fdb\u5165g0\/0\/0\u63a5\u53e3\n&#91;r1-GigabitEthernet0\/0\/0]ip address 192.168.10.2 24\tIP\u5730\u5740192.168.10.2 \u5b50\u7f51\u63a9\u780124\n&#91;r1-GigabitEthernet0\/0\/0]undo shutdown \u5173\u95ed\u6d88\u606f\u63a7\u5236\u53f0\nInfo: Interface GigabitEthernet0\/0\/0 is not shutdown.\n&#91;r1-GigabitEthernet0\/0\/0]quit \u9000\u51fa\n&#91;r1]interface g0\/0\/1 \u8fdb\u5165g0\/0\/1\u63a5\u53e3 \u8fdb\u5165g0\/0\/1\u63a5\u53e3\n&#91;r1-GigabitEthernet0\/0\/1]ip address 192.168.20.2 24 IP\u5730\u5740192.168.20.2 \u5b50\u7f51\u63a9\u780124\n&#91;r1-GigabitEthernet0\/0\/1]undo shutdown \u5173\u95ed\u6d88\u606f\u63a7\u5236\u53f0\nInfo: Interface GigabitEthernet0\/0\/1 is not shutdown.\n&#91;r1-GigabitEthernet0\/0\/1]quit \u9000\u51fa<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u56db\u3001\u914d\u7f6e\u4ea4\u6362\u673aospf\u8fdb\u7a0b\u53f7\u3001\u9aa8\u5e72\u533a\u57df\u53ca\u5ba3\u544a\u7f51\u6bb5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;3sw1]ospf 1 router-id 1.1.1.1 \u8fdb\u5165ospf\u8fdb\u7a0b\u53f7\u662f1\uff08\u8fdb\u7a0b\u53f7\u8303\u56f4\uff1a1-255\uff09\u8def\u7531\u7684IP\u53f7\u662f1.1.1.1\uff08\u53ef\u8bbe\u53ef\u4e0d\u8bbe\uff09\n&#91;3sw1-ospf-1]area 0 \u5ba3\u544a\u662f\u9aa8\u5e72\u533a\u57dfarea0\u5ba3\u544a\u662f\u9aa8\u5e72\u533a\u57dfarea0\n&#91;3sw1-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255 \u5ba3\u544a\u7684\u7f51\u6bb5192.168.10.0 \u53cd\u63a9\u7801\uff1a0.0.0.255\n&#91;3sw1-ospf-1-area-0.0.0.0]quit \u9000\u51fa\n&#91;3sw1-ospf-1]quit \u9000\u51fa<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;3sw2]ospf 1 router-id 2.2.2.2  ospf\u8fdb\u7a0b\u53f7\u662f1\uff08\u8fdb\u7a0b\u53f7\u8303\u56f4\uff1a1-255\uff09\u8def\u7531\u7684IP\u53f7\u662f2.2.2.2\uff08\u53ef\u8bbe\u53ef\u4e0d\u8bbe\uff09\n&#91;3sw2-ospf-1]area 0 \u5ba3\u544a\u662f\u9aa8\u5e72\u533a\u57dfarea0\n&#91;3sw2-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255 \u5ba3\u544a\u7684\u7f51\u6bb5192.168.20.0 \u53cd\u63a9\u7801\uff1a0.0.0.255\n&#91;3sw2-ospf-1-area-0.0.0.0]quit \u9000\u51fa\n&#91;3sw2-ospf-1]quit \u9000\u51fa<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e94\u3001\u914d\u7f6e\u8def\u7531\u5668R1 ospf\u8fdb\u7a0b\u53f7\u3001\u9aa8\u5e72\u533a\u57df\u53ca\u5ba3\u544a\u7f51\u6bb5<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;r1&gt;system-view \u8fdb\u5165\u89c6\u56fe\u6a21\u5f0f\nEnter system view, return user view with Ctrl+Z.\n&#91;r1]ospf 1 ospf\u8fdb\u7a0b\u53f7\u662f1\n&#91;r1-ospf-1]area 0 \u5ba3\u544a\u662f\u9aa8\u5e72\u533a\u57dfarea0\n&#91;r1-ospf-1-area-0.0.0.0]network 192.168.10.0 0.0.0.255 \u5ba3\u544a\u7684\u7f51\u6bb5192.168.10.0 \u53cd\u63a9\u7801\uff1a0.0.0.255\n&#91;r1-ospf-1-area-0.0.0.0]quit \u9000\u51fa\n&#91;r1-ospf-1]quit \u9000\u51fa\n&#91;r1]ospf 1\n&#91;r1-ospf-1]area 0 \u5ba3\u544a\u662f\u9aa8\u5e72\u533a\u57dfarea0\n&#91;r1-ospf-1-area-0.0.0.0]network 192.168.20.0 0.0.0.255 \u5ba3\u544a\u7684\u7f51\u6bb5192.168.20.0 \u53cd\u63a9\u7801\uff1a0.0.0.255\n&#91;r1-ospf-1-area-0.0.0.0]quit \u9000\u51fa\n&#91;r1-ospf-1]quit \u9000\u51fa<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u516d\u3001\u67e5\u770b\u8def\u7531\u8868\u4e2dOSPF\u8def\u7531\u8868\u534f\u8bae\u7684\u4fe1\u606f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;r1]display ip routing-table protocol ospf \u67e5\u770b\u8def\u7531\u8868\u4e2dOSPF\u8def\u7531\u8868\u534f\u8bae\u7684\u4fe1\u606f\n\nRoute Flags: R - relay, D - download to fib\n------------------------------------------------------------------------------\nPublic routing table : OSPF\n         Destinations : 1        Routes : 1        \n\nOSPF routing table status : &lt;Active&gt;\n         Destinations : 1        Routes : 1\n\nDestination\/Mask    Proto   Pre  Cost      Flags NextHop         Interface\n\n   192.168.20.0\/24  OSPF    10   2           D   192.168.10.2    Vlanif10  \u770b\u8fd9\u4e2a\n\nOSPF routing table status : &lt;Inactive&gt;\n         Destinations : 0        Routes : 0<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e03\u3001\u6d4b\u8bd5 3SW1 ping 3SW2 \u662f\u5426\u901a\u4fe1:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;3sw1]ping 192.168.20.1\n  PING 192.168.20.1: 56  data bytes, press CTRL_C to break\n    Reply from 192.168.20.1: bytes=56 Sequence=1 ttl=254 time=60 ms\n    Reply from 192.168.20.1: bytes=56 Sequence=2 ttl=254 time=60 ms\n    Reply from 192.168.20.1: bytes=56 Sequence=3 ttl=254 time=40 ms\n    Reply from 192.168.20.1: bytes=56 Sequence=4 ttl=254 time=60 ms\n    Reply from 192.168.20.1: bytes=56 Sequence=5 ttl=254 time=20 ms\n\n  --- 192.168.20.1 ping statistics ---\n    5 packet(s) transmitted\n    5 packet(s) received\n    0.00% packet loss\n    round-trip min\/avg\/max = 20\/48\/60 ms\n\n&#91;3sw1] User interface con0 is available<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u5b9e\u9a8c\u62d3\u6251\u56fe \u4e8c\u3001\u914d\u7f6e3SW1\u30013SW2 \u5212\u5206vlan\u3001\u914d\u7f6e\u865a\u63a5\u53e3IP\u3001\u5212\u5206\u63a5\u53e3vlan \u4e09\u3001\u8bbe\u7f6eR1\u8def\u7531\u5668 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[109,124],"tags":[138,139],"class_list":["post-1824","post","type-post","status-publish","format-standard","hentry","category-huawei","category-124","tag-138","tag-ospf"],"_links":{"self":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts\/1824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1824"}],"version-history":[{"count":2,"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts\/1824\/revisions"}],"predecessor-version":[{"id":1828,"href":"http:\/\/113.45.254.23\/index.php?rest_route=\/wp\/v2\/posts\/1824\/revisions\/1828"}],"wp:attachment":[{"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1824"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/113.45.254.23\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}