From 70bd794e24740c149b9fbdf5d9a468220dd2a8c2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 27 Apr 2024 11:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20240427\347\254\224\350\256\260.md" | 155 ++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 "\351\242\234\351\224\220\346\225\217/20240427\347\254\224\350\256\260.md" diff --git "a/\351\242\234\351\224\220\346\225\217/20240427\347\254\224\350\256\260.md" "b/\351\242\234\351\224\220\346\225\217/20240427\347\254\224\350\256\260.md" new file mode 100644 index 0000000..60497f6 --- /dev/null +++ "b/\351\242\234\351\224\220\346\225\217/20240427\347\254\224\350\256\260.md" @@ -0,0 +1,155 @@ +## 动态路由之OSPF + +1、新建拓扑图 + +2、配置IP地址和网关 + +PC4:192.168.1.1 192.168.1.254 + +PC5:192.168.2.1 192.168.2.254 + +3、配置路由器6 +```js + +Router>en +Router#conf t +Router(config)#int range f0/0-1 +Router(config-if-range)#no shut +Router(config-if-range)#int f0/0 +Router(config-if)#ip address 192.168.1.254 255.255.255.0 +Router(config-if)#int f0/1 +Router(config-if)#ip address 192.168.3.1 255.255.255.0 +Router(config-if)#route ospf 1 //进入路由器的OSPF模式,1是进程号,一般统一使用1 +Router(config-router)#network 192.168.1.0 0.0.0.255 area 0 //向其他路由器宣告自己的直连网络 +//0.0.0.255是反子网掩码,用255.255.255.255 - 255.255.255.0(子网掩码)得到的 +//area 区域 +//0 骨干网络 +Router(config-router)#network 192.168.3.0 0.0.0.255 area 0 + +``` +其他路由器同上 + +4、测试连通性 + +ping 192.168.2.1 + +### 单臂路由的OSPF模式 +1、新建拓扑图 + +2、配置IP和网关 + +PC0:192.168.1.1 192.168.1.254 + +PC2:192.168.10.1 192.168.10.254 + +PC3:192.168.20.1 192.168.20.254 + +PC1:192.168.2.1 192.168.2.254 + + +3、配置交换机 + +```js +Switch>en +Switch#conf t +Enter configuration commands, one per line. End with CNTL/Z. + +Switch(config)#int f0/1 +Switch(config-if)#sw ac vlan 10 +% Access VLAN does not exist. Creating vlan 10 + +Switch(config-if)#int f0/2 +Switch(config-if)#sw ac vlan 20 +% Access VLAN does not exist. Creating vlan 20 + +Switch(config-if)#int f0/3 +Switch(config-if)#sw ac vlan 30 +% Access VLAN does not exist. Creating vlan 30 + +Switch(config-if)# +%LINK-5-CHANGED: Interface FastEthernet0/4, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up + +Switch(config-if)#int f0/4 +Switch(config-if)#sw mode trunk + +``` + +4、配置路由Router0 + +```js +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. + +Router(config)#int f0/0 +Router(config-if)#no shut + +Router(config-if)#int f0/0.1 + +Router(config-subif)#encapsulation dot1Q 10 +Router(config-subif)#ip address 192.168.1.254 255.255.255.0 + +Router(config-subif)#int f0/0.2 +Router(config-subif)#encapsulation dot1Q 20 +Router(config-subif)#ip address 192.168.10.254 255.255.255.0 + +Router(config-subif)#int f0/0.3 +Router(config-subif)#encapsulation dot1Q 30 +Router(config-subif)#ip address 192.168.20.254 255.255.255.0 + +Router(config-subif)#int f0/1 +Router(config-if)#no shut +Router(config-if)#ip address 192.168.3.1 255.255.255.0 + +Router(config-if)#route ospf 1 +Router(config-router)#net 192.168.1.0 0.0.0.255 area 0 +Router(config-router)#net 192.168.10.0 0.0.0.255 area 0 +Router(config-router)#net 192.168.20.0 0.0.0.255 area 0 +``` + +5、配置路由Router1 + +```js +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. + +Router(config)#int range f0/0-1 +Router(config-if-range)#no shut + +Router(config-if-range)#int f0/0 +Router(config-if)#ip address 192.168.3.2 255.255.255.0 + +Router(config-if-range)#int f0/1 +Router(config-if)#ip address 192.168.4.1 255.255.255.0 + +Router(config-if)#route ospf 1 +Router(config-router)#net 192.168.3.0 0.0.0.255 area 0 +Router(config-router)#net 192.168.4.0 0.0.0.255 area 0 +``` + +6、配置路由Router2 + +```js + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. + +Router(config)#int f0/0 +Router(config-if)#no shut +Router(config-if)#ip address 192.168.4.2 255.255.255.0 + +Router(config-if)#int f0/1 +Router(config-if)#no shut +Router(config-if)#ip address 192.168.2.254 255.255.255.0 + +Router(config-if)#route ospf 1 +Router(config-router)#net 192.168.4.0 0.0.0.255 area 0 +Router(config-router)#net 192.168.2.0 0.0.0.255 area 0 + +``` + +7、测试连通性 \ No newline at end of file -- Gitee