路由器的路由配置
文章目录
路由器的路由配置路由器的静态配置实验拓扑图配置IP和环回IPAR1AR2AR3配置PCPC1PC2PC3配置路由器的静态路由AR1AR2AR3路由间的连通性AR1 ping AR2AR1 ping AR3AR2 ping AR3主机之间的连通性PC1 ping PC2PC1 ping PC3pc2 ping PC3OSPF动态规划路由实验拓扑图配置IP和环回IPAR1AR2AR3OSPF动态规划R1R2R3测试路由器的连通性R1 ping R2R1 ping R3R2 ping R3测试主机间的连通性PC1 ping PC2PC1 ping PC3PC2 ping PC3路由器的静态配置
实验拓扑图
配置IP和环回IP
AR1
<Huawei>system-view[Huawei]sysname R1[R1]interface LoopBack 0[R1-LoopBack0]ip address 1.1.1.1 32[R1-LoopBack0]quit[R1]interface g0/0/0[R1-GigabitEthernet0/0/0]ip ad[R1-GigabitEthernet0/0/0]ip address 10.1.12.1 24[R1-GigabitEthernet0/0/0]quit [R1]interface g0/0/1[R1-GigabitEthernet0/0/1]ip address 4.4.4.5 24[R1-GigabitEthernet0/0/1]quit
AR2
<R2>sys<R2>system-view R2]interface g0/0/0[R2-GigabitEthernet0/0/0]ip address 10.1.12.2 24[R2-GigabitEthernet0/0/0]quit [R2]interface g0/0/1[R2-GigabitEthernet0/0/1]ip address 10.1.23.2 24[R2-GigabitEthernet0/0/1]quit [R2]interface g0/0/2[R2-GigabitEthernet0/0/2]ip address 5.5.5.6 24[R2-GigabitEthernet0/0/2]quit [R2]interface g4/0/0[R2-GigabitEthernet4/0/0]ip address 10.1.34.2 24[R2-GigabitEthernet4/0/0]quit[R2]interface LoopBack 0[R2-LoopBack0]ip ad[R2-LoopBack0]ip address 2.2.2.2 32[R2-LoopBack0]quit
AR3
[R3]interface g0/0/0[R3-GigabitEthernet0/0/0]display this[R3-GigabitEthernet0/0/0]ip ad[R3-GigabitEthernet0/0/0]ip address 10.1.23.3 24[R3-GigabitEthernet0/0/0]quit[R3]int[R3]interface g0/0/1[R3-GigabitEthernet0/0/1]ip ad[R3-GigabitEthernet0/0/1]ip address 6.6.6.7 24[R3-GigabitEthernet0/0/1]quit [R3]int[R3]interface g0/0/2[R3-GigabitEthernet0/0/2]ip ad[R3-GigabitEthernet0/0/2]ip address 10.1.34.3 24[R3]interface LoopBack 0[R3-LoopBack0]ip ad[R3-LoopBack0]ip address 3.3.3.3 32[R3-LoopBack0]quit
配置PC
PC1
PC2
PC3
配置路由器的静态路由
AR1
[R1]ip route-static 10.1.23.0 24 10.1.12.2[R1]ip route-static 10.1.34.0 24 10.1.12.2[R1]ip route-static 5.5.5.0 24 10.1.12.2[R1]ip route-static 6.6.6.0 24 10.1.12.2[R1]ip route-static 2.2.2.2 32 10.1.12.2[R1]ip route-static 3.3.3.3 32 10.1.12.2
AR2
[R2]ip route-static 1.1.1.1 32 10.1.12.1[R2]ip route-static 3.3.3.3 32 10.1.23.3[R2]ip route-static 3.3.3.3 32 10.1.34.3[R2]ip route-static 4.4.4.0 24 10.1.12.1[R2]ip route-static 6.6.6.0 24 10.1.23.3[R2]ip route-static 6.6.6.0 24 10.1.34.3
AR3
[R3]ip route-static 2.2.2.2 32 10.1.23.2[R3]ip route-static 2.2.2.2 32 10.1.34.2[R3]ip route-static 1.1.1.1 32 10.1.23.2[R3]ip route-static 1.1.1.1 32 10.1.34.2[R3]ip route-static 10.1.12.0 24 10.1.23.2[R3]ip route-static 10.1.12.0 24 10.1.34.2[R3]ip route-static 5.5.5.0 24 10.1.23.2[R3]ip route-static 5.5.5.0 24 10.1.34.2[R3]ip route-static 4.4.4.0 24 10.1.23.2[R3]ip route-static 4.4.4.0 24 10.1.34.2
路由间的连通性
AR1 ping AR2
<R1>ping -a 1.1.1.1 2.2.2.2PING 2.2.2.2: 56 data bytes, press CTRL_C to breakReply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=10 msReply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=20 msReply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 msReply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 msReply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=20 ms<R1>ping 2.2.2.2PING 2.2.2.2: 56 data bytes, press CTRL_C to breakReply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=10 msReply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=20 msReply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=10 msReply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=1 msReply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=30 ms<R1>ping 10.1.12.2PING 10.1.12.2: 56 data bytes, press CTRL_C to breakReply from 10.1.12.2: bytes=56 Sequence=1 ttl=255 time=20 msReply from 10.1.12.2: bytes=56 Sequence=2 ttl=255 time=30 msReply from 10.1.12.2: bytes=56 Sequence=3 ttl=255 time=20 msReply from 10.1.12.2: bytes=56 Sequence=4 ttl=255 time=20 msReply from 10.1.12.2: bytes=56 Sequence=5 ttl=255 time=20 ms
AR1 ping AR3
<R1>ping 10.1.34.3PING 10.1.34.3: 56 data bytes, press CTRL_C to breakReply from 10.1.34.3: bytes=56 Sequence=1 ttl=254 time=20 msReply from 10.1.34.3: bytes=56 Sequence=2 ttl=254 time=20 msReply from 10.1.34.3: bytes=56 Sequence=3 ttl=254 time=20 msReply from 10.1.34.3: bytes=56 Sequence=4 ttl=254 time=20 msReply from 10.1.34.3: bytes=56 Sequence=5 ttl=254 time=20 ms<R1>ping 10.1.23.3PING 10.1.23.3: 56 data bytes, press CTRL_C to breakReply from 10.1.23.3: bytes=56 Sequence=1 ttl=254 time=20 msReply from 10.1.23.3: bytes=56 Sequence=2 ttl=254 time=20 msReply from 10.1.23.3: bytes=56 Sequence=3 ttl=254 time=30 msReply from 10.1.23.3: bytes=56 Sequence=4 ttl=254 time=20 msReply from 10.1.23.3: bytes=56 Sequence=5 ttl=254 time=20 ms<R1>ping -a 1.1.1.1 3.3.3.3PING 3.3.3.3: 56 data bytes, press CTRL_C to breakReply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=20 ms
AR2 ping AR3
<R2>ping 3.3.3.3PING 3.3.3.3: 56 data bytes, press CTRL_C to breakReply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=20 msReply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=20 msReply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=30 msReply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=20 msReply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=20 ms<R2>ping 10.1.23.3PING 10.1.23.3: 56 data bytes, press CTRL_C to breakReply from 10.1.23.3: bytes=56 Sequence=1 ttl=255 time=40 msReply from 10.1.23.3: bytes=56 Sequence=2 ttl=255 time=20 msReply from 10.1.23.3: bytes=56 Sequence=3 ttl=255 time=20 msReply from 10.1.23.3: bytes=56 Sequence=4 ttl=255 time=20 msReply from 10.1.23.3: bytes=56 Sequence=5 ttl=255 time=30 ms<R2>ping 10.1.34.3PING 10.1.34.3: 56 data bytes, press CTRL_C to breakReply from 10.1.34.3: bytes=56 Sequence=1 ttl=255 time=20 msReply from 10.1.34.3: bytes=56 Sequence=2 ttl=255 time=20 msReply from 10.1.34.3: bytes=56 Sequence=3 ttl=255 time=20 msReply from 10.1.34.3: bytes=56 Sequence=4 ttl=255 time=20 msReply from 10.1.34.3: bytes=56 Sequence=5 ttl=255 time=20 ms
主机之间的连通性
PC1 ping PC2
PC>ping 5.5.5.6Ping 5.5.5.6: 32 data bytes, Press Ctrl_C to breakFrom 5.5.5.6: bytes=32 seq=1 ttl=255 time<1 msFrom 5.5.5.6: bytes=32 seq=2 ttl=255 time=15 msFrom 5.5.5.6: bytes=32 seq=3 ttl=255 time<1 msFrom 5.5.5.6: bytes=32 seq=4 ttl=255 time=16 msFrom 5.5.5.6: bytes=32 seq=5 ttl=255 time<1 ms--- 5.5.5.6 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 0/6/16 ms
PC1 ping PC3
PC>ping 6.6.6.7Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to breakFrom 6.6.6.7: bytes=32 seq=1 ttl=254 time=32 msFrom 6.6.6.7: bytes=32 seq=2 ttl=254 time=15 msFrom 6.6.6.7: bytes=32 seq=3 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=4 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=5 ttl=254 time=31 ms--- 6.6.6.7 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 15/22/32 ms
pc2 ping PC3
PC>ping 6.6.6.7Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to breakFrom 6.6.6.7: bytes=32 seq=1 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=2 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=3 ttl=254 time=31 msFrom 6.6.6.7: bytes=32 seq=4 ttl=254 time=15 msFrom 6.6.6.7: bytes=32 seq=5 ttl=254 time=32 ms--- 6.6.6.7 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 15/22/32 ms
OSPF动态规划路由
实验拓扑图
配置IP和环回IP
AR1
<Huawei>system-view[Huawei]sysname R1[R1]interface LoopBack 0[R1-LoopBack0]ip address 1.1.1.1 32[R1-LoopBack0]quit[R1]interface g0/0/0[R1-GigabitEthernet0/0/0]ip ad[R1-GigabitEthernet0/0/0]ip address 10.1.12.1 24[R1-GigabitEthernet0/0/0]quit [R1]interface g0/0/1[R1-GigabitEthernet0/0/1]ip address 4.4.4.5 24[R1-GigabitEthernet0/0/1]quit
AR2
<R2>sys<R2>system-view R2]interface g0/0/0[R2-GigabitEthernet0/0/0]ip address 10.1.12.2 24[R2-GigabitEthernet0/0/0]quit [R2]interface g0/0/1[R2-GigabitEthernet0/0/1]ip address 10.1.23.2 24[R2-GigabitEthernet0/0/1]quit [R2]interface g0/0/2[R2-GigabitEthernet0/0/2]ip address 5.5.5.6 24[R2-GigabitEthernet0/0/2]quit [R2]interface g4/0/0[R2-GigabitEthernet4/0/0]ip address 10.1.34.2 24[R2-GigabitEthernet4/0/0]quit[R2]interface LoopBack 0[R2-LoopBack0]ip ad[R2-LoopBack0]ip address 2.2.2.2 32[R2-LoopBack0]quit
AR3
[R3]interface g0/0/0[R3-GigabitEthernet0/0/0]display this[R3-GigabitEthernet0/0/0]ip ad[R3-GigabitEthernet0/0/0]ip address 10.1.23.3 24[R3-GigabitEthernet0/0/0]quit[R3]int[R3]interface g0/0/1[R3-GigabitEthernet0/0/1]ip ad[R3-GigabitEthernet0/0/1]ip address 6.6.6.7 24[R3-GigabitEthernet0/0/1]quit [R3]int[R3]interface g0/0/2[R3-GigabitEthernet0/0/2]ip ad[R3-GigabitEthernet0/0/2]ip address 10.1.34.3 24[R3]interface LoopBack 0[R3-LoopBack0]ip ad[R3-LoopBack0]ip address 3.3.3.3 32[R3-LoopBack0]quit
OSPF动态规划
R1
[R1]ospf router-id 1.1.1.1[R1-ospf-1]area 0[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0 [R1-ospf-1-area-0.0.0.0]network 4.4.4.5 0.0.0.0 [R1-ospf-1-area-0.0.0.0] network 10.1.12.1 0.0.0.0
R2
[R2]ospf router-id 2.2.2.2[R2-ospf-1]area 0[R2-ospf-1-area-0.0.0.0]network 10.1.12.2 0.0.0.0 [R2-ospf-1-area-0.0.0.0]quit [R2-ospf-1]area 1[R2-ospf-1-area-0.0.0.1]network 2.2.2.2 0.0.0.0 [R2-ospf-1-area-0.0.0.1]network 5.5.5.6 0.0.0.0 [R2-ospf-1-area-0.0.0.1]network 10.1.23.2 0.0.0.0 [R2-ospf-1-area-0.0.0.1] network 10.1.34.2 0.0.0.0
R3
[R3]ospf router-id 3.3.3.3[R3-ospf-1]area 1[R3-ospf-1-area-0.0.0.1]network 3.3.3.3 0.0.0.0 [R3-ospf-1-area-0.0.0.1]network 6.6.6.7 0.0.0.0 [R3-ospf-1-area-0.0.0.1]network 10.1.23.3 0.0.0.0 [R3-ospf-1-area-0.0.0.1]network 10.1.34.3 0.0.0.0
测试路由器的连通性
R1 ping R2
<R1>ping 2.2.2.2PING 2.2.2.2: 56 data bytes, press CTRL_C to breakReply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=40 msReply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=30 msReply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 msReply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 msReply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=30 ms--- 2.2.2.2 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 20/28/40 ms
R1 ping R3
<R1>ping 3.3.3.3PING 3.3.3.3: 56 data bytes, press CTRL_C to breakReply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=20 msReply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=40 ms--- 3.3.3.3 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 20/30/40 ms
R2 ping R3
<R1>ping 3.3.3.3PING 3.3.3.3: 56 data bytes, press CTRL_C to breakReply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 msReply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=20 msReply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=40 ms--- 3.3.3.3 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 20/30/40 ms
测试主机间的连通性
PC1 ping PC2
PC>ping 5.5.5.6Ping 5.5.5.6: 32 data bytes, Press Ctrl_C to breakFrom 5.5.5.6: bytes=32 seq=1 ttl=254 time=16 msFrom 5.5.5.6: bytes=32 seq=2 ttl=254 time=15 msFrom 5.5.5.6: bytes=32 seq=3 ttl=254 time=16 msFrom 5.5.5.6: bytes=32 seq=4 ttl=254 time=16 msFrom 5.5.5.6: bytes=32 seq=5 ttl=254 time=31 ms--- 5.5.5.6 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 15/18/31 ms
PC1 ping PC3
PC>ping 6.6.6.7Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to breakFrom 6.6.6.7: bytes=32 seq=1 ttl=253 time=15 msFrom 6.6.6.7: bytes=32 seq=2 ttl=253 time=16 msFrom 6.6.6.7: bytes=32 seq=3 ttl=253 time=31 msFrom 6.6.6.7: bytes=32 seq=4 ttl=253 time=31 msFrom 6.6.6.7: bytes=32 seq=5 ttl=253 time=16 ms--- 6.6.6.7 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 15/21/31 ms
PC2 ping PC3
PC>ping 6.6.6.7Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to breakFrom 6.6.6.7: bytes=32 seq=1 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=2 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=3 ttl=254 time=15 msFrom 6.6.6.7: bytes=32 seq=4 ttl=254 time=16 msFrom 6.6.6.7: bytes=32 seq=5 ttl=254 time=16 ms--- 6.6.6.7 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 15/15/16 ms