路由器的静态路由配置以及OSPF动态配置

路由器的路由配置

文章目录

  • 路由器的路由配置
    • 路由器的静态配置
      • 实验拓扑图
        • 配置IP和环回IP
          • AR1
          • AR2
          • AR3
        • 配置PC
          • PC1
          • PC2
          • PC3
        • 配置路由器的静态路由
          • AR1
          • AR2
          • AR3
        • 路由间的连通性
          • AR1 ping AR2
          • AR1 ping AR3
          • AR2 ping AR3
        • 主机之间的连通性
          • PC1 ping PC2
          • PC1 ping PC3
          • pc2 ping PC3
    • OSPF动态规划路由
      • 实验拓扑图
        • 配置IP和环回IP
          • AR1
          • AR2
          • AR3
        • OSPF动态规划
          • R1
          • R2
          • R3
        • 测试路由器的连通性
          • R1 ping R2
          • R1 ping R3
          • R2 ping R3
        • 测试主机间的连通性
          • PC1 ping PC2
          • PC1 ping PC3
          • PC2 ping PC3

路由器的静态配置

实验拓扑图

路由器的静态路由配置以及OSPF动态配置_第1张图片

配置IP和环回IP

AR1
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
sys	
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

路由器的静态路由配置以及OSPF动态配置_第2张图片

PC2

路由器的静态路由配置以及OSPF动态配置_第3张图片

PC3

路由器的静态路由配置以及OSPF动态配置_第4张图片

配置路由器的静态路由

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
ping -a 1.1.1.1 2.2.2.2
  PING 2.2.2.2: 56  data bytes, press CTRL_C to break
    Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=10 ms
    Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=20 ms
ping 2.2.2.2
  PING 2.2.2.2: 56  data bytes, press CTRL_C to break
    Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=10 ms
    Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=10 ms
    Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=1 ms
    Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=30 ms
ping 10.1.12.2
  PING 10.1.12.2: 56  data bytes, press CTRL_C to break
    Reply from 10.1.12.2: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 10.1.12.2: bytes=56 Sequence=2 ttl=255 time=30 ms
    Reply from 10.1.12.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 10.1.12.2: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 10.1.12.2: bytes=56 Sequence=5 ttl=255 time=20 ms
AR1 ping AR3
ping 10.1.34.3
  PING 10.1.34.3: 56  data bytes, press CTRL_C to break
    Reply from 10.1.34.3: bytes=56 Sequence=1 ttl=254 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=3 ttl=254 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=5 ttl=254 time=20 ms
ping 10.1.23.3
  PING 10.1.23.3: 56  data bytes, press CTRL_C to break
    Reply from 10.1.23.3: bytes=56 Sequence=1 ttl=254 time=20 ms
    Reply from 10.1.23.3: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 10.1.23.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 10.1.23.3: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 10.1.23.3: bytes=56 Sequence=5 ttl=254 time=20 ms
ping -a 1.1.1.1 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=20 ms
AR2 ping AR3
ping 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=20 ms
ping 10.1.23.3
  PING 10.1.23.3: 56  data bytes, press CTRL_C to break
    Reply from 10.1.23.3: bytes=56 Sequence=1 ttl=255 time=40 ms
    Reply from 10.1.23.3: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.23.3: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 10.1.23.3: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 10.1.23.3: bytes=56 Sequence=5 ttl=255 time=30 ms
ping 10.1.34.3
  PING 10.1.34.3: 56  data bytes, press CTRL_C to break
    Reply from 10.1.34.3: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 10.1.34.3: bytes=56 Sequence=5 ttl=255 time=20 ms

主机之间的连通性

PC1 ping PC2
PC>ping 5.5.5.6

Ping 5.5.5.6: 32 data bytes, Press Ctrl_C to break
From 5.5.5.6: bytes=32 seq=1 ttl=255 time<1 ms
From 5.5.5.6: bytes=32 seq=2 ttl=255 time=15 ms
From 5.5.5.6: bytes=32 seq=3 ttl=255 time<1 ms
From 5.5.5.6: bytes=32 seq=4 ttl=255 time=16 ms
From 5.5.5.6: bytes=32 seq=5 ttl=255 time<1 ms

--- 5.5.5.6 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 0/6/16 ms

PC1 ping PC3
PC>ping 6.6.6.7

Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to break
From 6.6.6.7: bytes=32 seq=1 ttl=254 time=32 ms
From 6.6.6.7: bytes=32 seq=2 ttl=254 time=15 ms
From 6.6.6.7: bytes=32 seq=3 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=4 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=5 ttl=254 time=31 ms

--- 6.6.6.7 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/22/32 ms

pc2 ping PC3
PC>ping 6.6.6.7

Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to break
From 6.6.6.7: bytes=32 seq=1 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=2 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=3 ttl=254 time=31 ms
From 6.6.6.7: bytes=32 seq=4 ttl=254 time=15 ms
From 6.6.6.7: bytes=32 seq=5 ttl=254 time=32 ms

--- 6.6.6.7 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/22/32 ms

OSPF动态规划路由

实验拓扑图

路由器的静态路由配置以及OSPF动态配置_第5张图片

配置IP和环回IP

AR1
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
sys	
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
ping 2.2.2.2
  PING 2.2.2.2: 56  data bytes, press CTRL_C to break
    Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=40 ms
    Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=30 ms
    Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=30 ms

  --- 2.2.2.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/40 ms
R1 ping R3
ping 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=40 ms

  --- 3.3.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/30/40 ms
R2 ping R3
ping 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=40 ms

  --- 3.3.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/30/40 ms

测试主机间的连通性

PC1 ping PC2
PC>ping 5.5.5.6

Ping 5.5.5.6: 32 data bytes, Press Ctrl_C to break
From 5.5.5.6: bytes=32 seq=1 ttl=254 time=16 ms
From 5.5.5.6: bytes=32 seq=2 ttl=254 time=15 ms
From 5.5.5.6: bytes=32 seq=3 ttl=254 time=16 ms
From 5.5.5.6: bytes=32 seq=4 ttl=254 time=16 ms
From 5.5.5.6: bytes=32 seq=5 ttl=254 time=31 ms

--- 5.5.5.6 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/18/31 ms

PC1 ping PC3
PC>ping 6.6.6.7

Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to break
From 6.6.6.7: bytes=32 seq=1 ttl=253 time=15 ms
From 6.6.6.7: bytes=32 seq=2 ttl=253 time=16 ms
From 6.6.6.7: bytes=32 seq=3 ttl=253 time=31 ms
From 6.6.6.7: bytes=32 seq=4 ttl=253 time=31 ms
From 6.6.6.7: bytes=32 seq=5 ttl=253 time=16 ms

--- 6.6.6.7 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/21/31 ms

PC2 ping PC3
PC>ping 6.6.6.7

Ping 6.6.6.7: 32 data bytes, Press Ctrl_C to break
From 6.6.6.7: bytes=32 seq=1 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=2 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=3 ttl=254 time=15 ms
From 6.6.6.7: bytes=32 seq=4 ttl=254 time=16 ms
From 6.6.6.7: bytes=32 seq=5 ttl=254 time=16 ms

--- 6.6.6.7 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 15/15/16 ms

你可能感兴趣的:(路由器,网络,动态规划,计算机网络)