IP相关问题8 --- BGP小综合

实验要求:

1.R2-7每台路由器均存在一个环回接口用于建立邻居;同时还存在一个环回来代表连
接用户的接口;最终这些连接用户的接口网络需要可以和R1/8的环回通讯
2.AS2网段地址172.16.0.0/16减少路由条目数量

1.ip地址规划

由于AS2网段地址为172.16.0.0/16 可将其分为8个分别为:

172.16.0.0/24        再将其分为两个掩码为25的IP

        172.16.0.0/25        再将其分为掩码为30的ip供p2p使用

        172.16.0.128/25        再将其分为掩码为29的ip供MA使用

172.16.1.0/24        再将其分为掩码为32的环回供宣告使用

        172.16.1.2/32

        172.16.1.3/32

        ……

        

172.16.2.0/24

172.16.3.0/24

……

172.6.7.0/24

2.配置ip地址

1.配置R2-R7上供建邻的环回地址

[Huawei]sysname r2
[r2]int lo0
[r2-LoopBack0]ip add 172.16.1.2 32

[Huawei]sysname r3
[r3]int lo0
[r3-LoopBack0]ip add 172.16.1.3 32

[Huawei]sysname  r4
[r4]int lo0
[r4-LoopBack0]ip add 172.16.1.4 32

[Huawei]sysname r5
[r5]int lo0
[r5-LoopBack0]ip add 172.16.1.5 32

[Huawei]sysname r6
[r6]int lo0
[r6-LoopBack0]ip add 172.16.1.6 32

[Huawei]sysname r7
[r7]int lo0
[r7-LoopBack0]ip add 172.16.1.7 32

 2.配置R2-R7上的用户环回

[r2-GigabitEthernet0/0/0]int lo1
[r2-LoopBack1]ip add 172.16.2.1 24

[r3]int lo1
[r3-LoopBack1]ip add 172.16.3.1 24

[r4]int lo1
[r4-LoopBack1]ip add 172.16.4.1 24

[r5]int lo1
[r5-LoopBack1]ip add 172.16.5.1 24

[r6]int lo1
[r6-LoopBack1]ip add 172.16.6.1 24

[r7]int lo1
[r7-LoopBack1]ip add 172.16.7.1 24

3.配置R1 R2物理ip地址

[r1]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 12.1.1.1 24
Aug 13 2023 18:37:23-08:00 r1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
Aug 13 2023 18:38:19-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 


4.配置骨干链路ip地址

[r2-LoopBack1]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 172.16.0.1 30
[r2-GigabitEthernet0/0/1]
Aug 13 2023 19:08:50-08:00 r2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 172.16.0.2 30
Aug 13 2023 19:09:47-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 172.16.0.5 30
Aug 13 2023 19:11:10-08:00 r3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 172.16.0.6 30
Aug 13 2023 19:17:08-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 

[r2]int g0/0/2
[r2-GigabitEthernet0/0/2]ip add 172.16.0.9 30
Aug 13 2023 20:19:24-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/2 has entered the UP state. 

[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 172.16.0.10 30
Aug 13 2023 20:20:51-08:00 r5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 

[r5]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 172.16.0.13 30
Aug 13 2023 20:21:55-08:00 r5 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[r6]int g0/0/0
[r6-GigabitEthernet0/0/0]ip add 172.16.0.14 30
Aug 13 2023 20:23:39-08:00 r6 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 

[r6]int g0/0/1
[r6-GigabitEthernet0/0/1]ip add 172.16.0.17 30
Aug 13 2023 20:24:31-08:00 r6 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[r7]int g0/0/0
[r7-GigabitEthernet0/0/0]ip add 172.16.0.18 30
Aug 13 2023 20:25:11-08:00 r7 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state.

[r4]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 172.16.0.21 30
Aug 13 2023 20:30:04-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state.

[r7-GigabitEthernet0/0/1]int g0/0/2
[r7-GigabitEthernet0/0/2]ip add 172.16.0.22 30
Aug 13 2023 20:30:38-08:00 r7 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP 
on the interface GigabitEthernet0/0/2 has entered the UP state.

5.配置R7 R8物理ip地址 

[r7-GigabitEthernet0/0/0]int g0/0/1
[r7-GigabitEthernet0/0/1]ip add 78.1.1.1 24
[r7-GigabitEthernet0/0/1]
Aug 13 2023 20:27:24-08:00 r7 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[r8]int g0/0/0
[r8-GigabitEthernet0/0/0]ip add 78.1.1.2 24
Aug 13 2023 20:28:10-08:00 r8 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r8]int lo0
[r8-LoopBack0]ip add 8.8.8.8 24

6.检测是否配置成功

[r2]ping 172.16.0.2
  PING 172.16.0.2: 56  data bytes, press CTRL_C to break
    Reply from 172.16.0.2: bytes=56 Sequence=1 ttl=255 time=150 ms
    Reply from 172.16.0.2: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 172.16.0.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 172.16.0.2: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 172.16.0.2: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 172.16.0.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/46/150 ms

[r2]ping 172.16.0.10
  PING 172.16.0.10: 56  data bytes, press CTRL_C to break
    Reply from 172.16.0.10: bytes=56 Sequence=1 ttl=255 time=80 ms
    Reply from 172.16.0.10: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 172.16.0.10: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 172.16.0.10: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 172.16.0.10: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 172.16.0.10 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/32/80 ms

[r3]ping 172.16.0.6
  PING 172.16.0.6: 56  data bytes, press CTRL_C to break
    Reply from 172.16.0.6: bytes=56 Sequence=1 ttl=255 time=90 ms
    Reply from 172.16.0.6: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 172.16.0.6: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 172.16.0.6: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 172.16.0.6: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 172.16.0.6 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/34/90 ms

[r5]ping 172.16.0.14
  PING 172.16.0.14: 56  data bytes, press CTRL_C to break
    Reply from 172.16.0.14: bytes=56 Sequence=1 ttl=255 time=80 ms
    Reply from 172.16.0.14: bytes=56 Sequence=2 ttl=255 time=40 ms
    Reply from 172.16.0.14: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 172.16.0.14: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 172.16.0.14: bytes=56 Sequence=5 ttl=255 time=30 ms

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

[r6]ping 172.16.0.18
  PING 172.16.0.18: 56  data bytes, press CTRL_C to break
    Reply from 172.16.0.18: bytes=56 Sequence=1 ttl=255 time=60 ms
    Reply from 172.16.0.18: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 172.16.0.18: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 172.16.0.18: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 172.16.0.18: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 172.16.0.18 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/60 ms

[r4]ping 172.16.0.22
  PING 172.16.0.22: 56  data bytes, press CTRL_C to break
    Reply from 172.16.0.22: bytes=56 Sequence=1 ttl=255 time=60 ms
    Reply from 172.16.0.22: bytes=56 Sequence=2 ttl=255 time=40 ms
    Reply from 172.16.0.22: bytes=56 Sequence=3 ttl=255 time=10 ms
    Reply from 172.16.0.22: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 172.16.0.22: bytes=56 Sequence=5 ttl=255 time=30 ms

  --- 172.16.0.22 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/34/60 ms

3.配置运行IGP

1.宣告ospf

[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0	
[r3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]net	
[r5-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 0
[r6-ospf-1-area-0.0.0.0]net	
[r6-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

[r7]ospf 1 router-id 7.7.7.7
[r7-ospf-1]area 0
[r7-ospf-1-area-0.0.0.0]net	
[r7-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255

2.检查是否宣告成功

[r2]display ospf peer brief 

	 OSPF Process 1 with Router ID 2.2.2.2
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/1             3.3.3.3          Full        
 0.0.0.0          GigabitEthernet0/0/2             5.5.5.5          Full        
 ----------------------------------------------------------------------------

[r7]display ospf peer brief 

	 OSPF Process 1 with Router ID 7.7.7.7
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             6.6.6.6          Full        
 0.0.0.0          GigabitEthernet0/0/2             4.4.4.4          Full        
 ----------------------------------------------------------------------------

[r3]display ospf peer brief 

	 OSPF Process 1 with Router ID 3.3.3.3
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 0.0.0.0          GigabitEthernet0/0/1             4.4.4.4          Full        
 ----------------------------------------------------------------------------

[r6]display ospf peer brief 

	 OSPF Process 1 with Router ID 6.6.6.6
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             5.5.5.5          Full        
 0.0.0.0          GigabitEthernet0/0/1             7.7.7.7          Full        
 ----------------------------------------------------------------------------

3.修改接口的工作方式

由于是32位的环回而我们需要24位的环回,真实情况下没有用户环回只有用户网段,所以需要修改接口工作方式

[r2]display ip routing-table protocol ospf

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

     172.16.0.4/30  OSPF    10   2           D   172.16.0.2      GigabitEthernet
0/0/1
    172.16.0.12/30  OSPF    10   2           D   172.16.0.10     GigabitEthernet
0/0/2
    172.16.0.16/30  OSPF    10   3           D   172.16.0.10     GigabitEthernet
0/0/2
    172.16.0.20/30  OSPF    10   3           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.1.3/32  OSPF    10   1           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.1.4/32  OSPF    10   2           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.1.5/32  OSPF    10   1           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.1.6/32  OSPF    10   2           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.1.7/32  OSPF    10   3           D   172.16.0.10     GigabitEthernet
0/0/2
                    OSPF    10   3           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.3.1/32  OSPF    10   1           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.4.1/32  OSPF    10   2           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.5.1/32  OSPF    10   1           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.6.1/32  OSPF    10   2           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.7.1/32  OSPF    10   3           D   172.16.0.10     GigabitEthernet
0/0/2
                    OSPF    10   3           D   172.16.0.2      GigabitEthernet
0/0/1

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

1.修改接口工作方式 

[r2]int lo1
[r2-LoopBack1]ospf network-type  broadcast 

[r3]int lo1	
[r3-LoopBack1]ospf network-type broadcast 

[r4]int lo1
[r4-LoopBack1]ospf network-type broadcast 

[r5]int lo1
[r5-LoopBack1]ospf network-type broadcast 

[r6]int lo1	
[r6-LoopBack1]ospf network-type broadcast

[r7]int lo1	
[r7-LoopBack1]ospf network-type broadcast 

2.查看修改是否完成 

[r2]display ip routing-table protocol ospf

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

     172.16.0.4/30  OSPF    10   2           D   172.16.0.2      GigabitEthernet
0/0/1
    172.16.0.12/30  OSPF    10   2           D   172.16.0.10     GigabitEthernet
0/0/2
    172.16.0.16/30  OSPF    10   3           D   172.16.0.10     GigabitEthernet
0/0/2
    172.16.0.20/30  OSPF    10   3           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.1.3/32  OSPF    10   1           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.1.4/32  OSPF    10   2           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.1.5/32  OSPF    10   1           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.1.6/32  OSPF    10   2           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.1.7/32  OSPF    10   3           D   172.16.0.10     GigabitEthernet
0/0/2
                    OSPF    10   3           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.3.0/24  OSPF    10   1           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.4.0/24  OSPF    10   2           D   172.16.0.2      GigabitEthernet
0/0/1
     172.16.5.0/24  OSPF    10   1           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.6.0/24  OSPF    10   2           D   172.16.0.10     GigabitEthernet
0/0/2
     172.16.7.0/24  OSPF    10   3           D   172.16.0.2      GigabitEthernet
0/0/1
                    OSPF    10   3           D   172.16.0.10     GigabitEthernet
0/0/2

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

4.配置运行BGP

1.BGP建邻

[r1]bgp 1
[r1-bgp]router-id 1.1.1.1	
[r1-bgp]peer 12.1.1.2 as-number 2

[r2]bgp 64512
[r2-bgp]router-id 2.2.2.2
[r2-bgp]confederation id 2
[r2-bgp]confederation peer-as 64513
[r2-bgp]peer 12.1.1.1 as-number 1
[r2-bgp]peer 172.16.1.3 as-number 64513
[r2-bgp]peer 172.16.1.3 connect-interface lo0	
[r2-bgp]peer 172.16.1.5 as-number 64513
[r2-bgp]peer 172.16.1.5 connect-interface lo0
[r2-bgp]peer 172.16.1.5 ebgp-max-hop 2

[r3]bgp 64512
[r3-bgp]router-id 3.3.3.3
[r3-bgp]confederation id 2
[r3-bgp]peer 172.16.1.2 as-number 64512
[r3-bgp]peer 172.16.1.2 connect-interface lo0
[r3-bgp]peer 172.16.1.4 as-number 64512
[r3-bgp]peer 172.16.1.4 connect-interface lo0

[r4]bgp 64512
[r4-bgp]router-id 4.4.4.4
[r4-bgp]confederation id 2
[r4-bgp]confederation peer-as 64513
[r4-bgp]peer 172.16.1.3 as-number 64512
[r4-bgp]peer 172.16.1.3 connect-interface lo0	
[r4-bgp]peer 172.16.1.7 as-number 64513
[r4-bgp]peer 172.16.1.7 connect-interface lo0
[r4-bgp]peer 172.16.1.7 ebgp-max-hop 2

[r5]bgp 64513
[r5-bgp]router-id 5.5.5.5
[r5-bgp]confederation id 2
[r5-bgp]confederation peer-as 64512
[r5-bgp]peer 172.16.1.2 as-number 64512
[r5-bgp]peer 172.16.1.2 connect-interface lo0
[r5-bgp]peer 172.16.1.2 ebgp-max-hop 2
[r5-bgp]peer 172.16.1.6 as-number 64513
[r5-bgp]peer 172.16.1.6 connect-interface lo0

[r6]bgp 64513
[r6-bgp]router-id 6.6.6.6
[r6-bgp]confederation id 2
[r6-bgp]peer 172.16.1.5 as-number 64513
[r6-bgp]peer 172.16.1.5 connect-interface lo0
[r6-bgp]peer 172.16.1.7 as-number 64513
[r6-bgp]peer 172.16.1.7 connect-interface lo0

[r7]bgp 64513
[r7-bgp]router-id 7.7.7.7
[r7-bgp]confederation  id 2
[r7-bgp]confederation  peer-as 64512
[r7-bgp]peer 172.16.1.6 as-number 64513
[r7-bgp]peer 172.16.1.6 connect-interface lo0
[r7-bgp]peer 172.16.1.4 as-number 64512
[r7-bgp]peer 172.16.1.4 connect-interface lo0
[r7-bgp]peer 172.16.1.4 ebgp-max-hop 2
[r7-bgp]peer 78.1.1.2 as	
[r7-bgp]peer 78.1.1.2 as-number 3

[r8]bgp 3	
[r8-bgp]router-id 8.8.8.8
[r8-bgp]peer 78.1.1.1 as-number 2

5.宣告BGP

[r1]bgp 1
[r1-bgp]net	
[r1-bgp]network 1.1.1.0 24
 
[r8]bgp 3
[r8-bgp]net	
[r8-bgp]network 8.8.8.0 24

 6.打破IBGP水平分割

[r3]bgp 64512
[r3-bgp]peer 172.16.1.1 reflect-client 

 
[r6]bgp 64513
[r6-bgp]peer 172.16.1.21 reflect-client

7. R2和R7上修改下一跳

[r2-bgp]peer 172.16.1.13 next-hop-local
[r2-bgp]peer 172.16.1.5 next-hop-local
 
[r7-bgp]peer 172.16.1.9 next-hop-local
[r7-bgp]peer 172.16.1.17next-hop-local

8.空接口防环

[r2]ip route-static 172.16.0.0 21 NULL 0
[r2-bgp]network 172.16.0.0 21
[r7]ip route-static 172.16.0.0 21 NULL 0
[r7-bgp]network 172.16.0.0 21

 9.检测是否联通

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值